Skip to content

Commit 46ed7cb

Browse files
committed
chore: read commit SHA from event file
1 parent 88bc0c6 commit 46ed7cb

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

dist/index.js

Lines changed: 9 additions & 1 deletion
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/upload.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,21 @@ export async function upload({
4747
formData.append('ci_platform', 'github')
4848

4949
if (process.env.GITHUB_SHA) {
50-
formData.append('commit_sha', process.env.GITHUB_SHA)
50+
let commitSha = process.env.GITHUB_SHA
51+
52+
if (
53+
process.env.GITHUB_EVENT_NAME === 'pull_request' &&
54+
process.env.GITHUB_EVENT_PATH
55+
) {
56+
const event = JSON.parse(
57+
fs.readFileSync(process.env.GITHUB_EVENT_PATH, 'utf-8')
58+
)
59+
if (event?.pull_request?.head?.sha) {
60+
commitSha = event.pull_request.head.sha
61+
}
62+
}
63+
64+
formData.append('commit_sha', commitSha)
5165
}
5266

5367
if (dryRun) {

0 commit comments

Comments
 (0)