Skip to content

Commit

Permalink
feat: use shorthened git commit id, change output variable to version…
Browse files Browse the repository at this point in the history
… tag
  • Loading branch information
gjedlicska committed Sep 18, 2023
1 parent 4599eff commit ea219de
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
16 changes: 11 additions & 5 deletions dist/action/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/action/index.js.map

Large diffs are not rendered by default.

16 changes: 11 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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)}`
)
Expand All @@ -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()

0 comments on commit ea219de

Please sign in to comment.