Skip to content

Commit

Permalink
Improve logging & fix wrong SHA used
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Dorner committed Feb 17, 2021
1 parent c5671cf commit 96237b3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion 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.

4 changes: 3 additions & 1 deletion src/utils/github-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const asyncStream = promisify(stream.pipeline)

export function getCheckRunContext(): {sha: string; runId: number} {
if (github.context.eventName === 'workflow_run') {
core.info('Action was triggered by workflow_run: using SHA and RUN_ID from triggering workflow')
const event = github.context.payload as EventPayloads.WebhookPayloadWorkflowRun
if (!event.workflow_run) {
throw new Error("Event of type 'workflow_run' is missing 'workflow_run' field")
Expand All @@ -21,7 +22,8 @@ export function getCheckRunContext(): {sha: string; runId: number} {
}

const runId = github.context.runId
if (github.context.eventName === 'pullrequest' && github.context.payload.pull_request) {
if (github.context.payload.pull_request) {
core.info(`Action was triggered by ${github.context}: using SHA from head of source branch`)
const pr = github.context.payload.pull_request as EventPayloads.WebhookPayloadPullRequestPullRequest
return {sha: pr.head.sha, runId}
}
Expand Down

0 comments on commit 96237b3

Please sign in to comment.