Improve logging & fix wrong SHA used

This commit is contained in:
Michal Dorner 2021-02-17 08:28:52 +01:00
parent c5671cf48a
commit 96237b3119
No known key found for this signature in database
GPG key ID: 9EEE04B48DA36786
3 changed files with 7 additions and 3 deletions

4
dist/index.js generated vendored
View file

@ -1378,6 +1378,7 @@ const got_1 = __importDefault(__nccwpck_require__(3061));
const asyncStream = util_1.promisify(stream.pipeline);
function getCheckRunContext() {
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;
if (!event.workflow_run) {
throw new Error("Event of type 'workflow_run' is missing 'workflow_run' field");
@ -1388,7 +1389,8 @@ function getCheckRunContext() {
};
}
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;
return { sha: pr.head.sha, runId };
}

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View file

@ -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")
@ -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}
}