Skip to content

Commit

Permalink
feat: support to auto detect sha
Browse files Browse the repository at this point in the history
  • Loading branch information
ArcticLampyrid committed Apr 19, 2024
1 parent c700620 commit da2316a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
1 change: 1 addition & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ inputs:
sha:
description: Commit sha
required: false
default: 'auto'
branch:
description: Branch name
required: false
Expand Down
21 changes: 16 additions & 5 deletions dist/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/index.js.map

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,16 @@ async function main(): Promise<void> {
parseInt(core.getInput('wait-interval', {required: true}), 10),
5
)
const sha = core.getInput('sha')
let sha = core.getInput('sha')
if (sha === 'auto') {
const pr_head_sha = github.context.payload.pull_request?.head?.sha
if (typeof pr_head_sha === 'string' && pr_head_sha.length > 0) {
sha = pr_head_sha
} else {
sha = github.context.sha
}
core.info(`Auto detected sha: ${sha}`)
}
const branch = core.getInput('branch')
const event = core.getInput('event')
const allowedConclusions = core.getMultilineInput(
Expand Down

0 comments on commit da2316a

Please sign in to comment.