1 Commits

Author SHA1 Message Date
Gergő Jedlicska ea219ded92 feat: use shorthened git commit id, change output variable to version tag 2023-09-18 17:26:12 +02:00
3 changed files with 23 additions and 11 deletions
Generated Vendored
+11 -5
View File
@@ -14083,11 +14083,13 @@ const parseEnvVars = () => {
const FunctionVersionResponseBodySchema = z.object({
versionId: z.string().nonempty()
});
const registerNewVersionForTheSpeckleAutomateFunction = async ({ speckleAutomateUrl, speckleFunctionCommand, speckleFunctionId, speckleFunctionInputSchema, speckleToken }, { gitCommitSha, gitRefName, gitRefType }) => {
const registerNewVersionForTheSpeckleAutomateFunction = async ({ speckleAutomateUrl, speckleFunctionCommand, speckleFunctionId, speckleFunctionInputSchema, speckleToken }, { commitId, versionTag }
// { gitCommitSha, gitRefName, gitRefType }: RequiredEnvVars
) => {
try {
const requestBody = {
commitId: gitCommitSha,
versionTag: gitRefType === 'tag' ? gitRefName : gitCommitSha,
commitId,
versionTag,
command: speckleFunctionCommand,
inputSchema: speckleFunctionInputSchema
};
@@ -14135,13 +14137,17 @@ async function run() {
const inputVariables = parseInputs();
core.info(`Parsed input variables to: ${JSON.stringify(inputVariables)}`);
const requiredEnvVars = parseEnvVars();
const { gitCommitSha, gitRefName, gitRefType } = requiredEnvVars;
core.info(`Parsed required environment variables to: ${JSON.stringify(requiredEnvVars)}`);
const { speckleAutomateUrl, speckleFunctionId } = inputVariables;
core.setOutput('speckle_automate_host', new URL(speckleAutomateUrl).host);
core.info(`Sending a new function version definition for function ${speckleFunctionId} to the automate server: ${speckleAutomateUrl}`);
const { versionId } = await registerNewVersionForTheSpeckleAutomateFunction(inputVariables, requiredEnvVars);
core.setOutput('version_id', versionId);
// github uses 7 chars to identify commits
const commitId = gitCommitSha.substring(0, 7);
const versionTag = gitRefType === 'tag' ? gitRefName : commitId;
const { versionId } = await registerNewVersionForTheSpeckleAutomateFunction(inputVariables, { versionTag, commitId });
core.info(`Registered function version with new id: ${versionId}`);
core.setOutput('version_tag', versionTag);
}
run();
Generated Vendored
+1 -1
View File
File diff suppressed because one or more lines are too long
+11 -5
View File
@@ -92,12 +92,13 @@ const registerNewVersionForTheSpeckleAutomateFunction = async (
speckleFunctionInputSchema,
speckleToken
}: InputVariables,
{ gitCommitSha, gitRefName, gitRefType }: RequiredEnvVars
{ commitId, versionTag }: { commitId: string; versionTag: string }
// { gitCommitSha, gitRefName, gitRefType }: RequiredEnvVars
): Promise<FunctionVersionResponseBody> => {
try {
const requestBody: FunctionVersionRequestBody = {
commitId: gitCommitSha,
versionTag: gitRefType === 'tag' ? gitRefName : gitCommitSha,
commitId,
versionTag,
command: speckleFunctionCommand,
inputSchema: speckleFunctionInputSchema
}
@@ -156,6 +157,7 @@ export async function run(): Promise<void> {
const inputVariables = parseInputs()
core.info(`Parsed input variables to: ${JSON.stringify(inputVariables)}`)
const requiredEnvVars = parseEnvVars()
const { gitCommitSha, gitRefName, gitRefType } = requiredEnvVars
core.info(
`Parsed required environment variables to: ${JSON.stringify(requiredEnvVars)}`
)
@@ -166,12 +168,16 @@ export async function run(): Promise<void> {
`Sending a new function version definition for function ${speckleFunctionId} to the automate server: ${speckleAutomateUrl}`
)
// github uses 7 chars to identify commits
const commitId = gitCommitSha.substring(0, 7)
const versionTag = gitRefType === 'tag' ? gitRefName : commitId
const { versionId } = await registerNewVersionForTheSpeckleAutomateFunction(
inputVariables,
requiredEnvVars
{ versionTag, commitId }
)
core.setOutput('version_id', versionId)
core.info(`Registered function version with new id: ${versionId}`)
core.setOutput('version_tag', versionTag)
}
run()