Skip to content

Commit da2316a

Browse files
feat: support to auto detect sha
1 parent c700620 commit da2316a

File tree

4 files changed

+28
-7
lines changed

4 files changed

+28
-7
lines changed

action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ inputs:
1919
sha:
2020
description: Commit sha
2121
required: false
22+
default: 'auto'
2223
branch:
2324
description: Branch name
2425
required: false

dist/index.js

Lines changed: 16 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,16 @@ async function main(): Promise<void> {
1111
parseInt(core.getInput('wait-interval', {required: true}), 10),
1212
5
1313
)
14-
const sha = core.getInput('sha')
14+
let sha = core.getInput('sha')
15+
if (sha === 'auto') {
16+
const pr_head_sha = github.context.payload.pull_request?.head?.sha
17+
if (typeof pr_head_sha === 'string' && pr_head_sha.length > 0) {
18+
sha = pr_head_sha
19+
} else {
20+
sha = github.context.sha
21+
}
22+
core.info(`Auto detected sha: ${sha}`)
23+
}
1524
const branch = core.getInput('branch')
1625
const event = core.getInput('event')
1726
const allowedConclusions = core.getMultilineInput(

0 commit comments

Comments
 (0)