Skip to content

Commit bc3dcde

Browse files
committed
Debug
1 parent 8eabb2b commit bc3dcde

File tree

6 files changed

+39
-13
lines changed

6 files changed

+39
-13
lines changed

.github/actions/reports-group/attach-check-run-to-triggering-workflow-action/action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ inputs:
66
name:
77
description: Status check name
88
required: true
9-
commit-sha:
10-
description: Commit SHA to attach to the check
11-
required: true
9+
# commit-sha:
10+
# description: Commit SHA to attach to the check
11+
# required: true
1212
github-token:
1313
description: Github Authentication token used to create the check through GitHub API
1414
required: true

.github/actions/reports-group/attach-check-run-to-triggering-workflow-action/dist/index.js

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

.github/actions/reports-group/attach-check-run-to-triggering-workflow-action/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.

.github/actions/reports-group/attach-check-run-to-triggering-workflow-action/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
},
1111
"dependencies": {
1212
"@actions/core": "^1.10.1",
13-
"@actions/github": "^6.0.0"
13+
"@actions/github": "^6.0.0",
14+
"@octokit/webhooks-definitions": "^3.67.3"
1415
},
1516
"devDependencies": {
1617
"@vercel/ncc": "^0.38.1"

.github/actions/reports-group/attach-check-run-to-triggering-workflow-action/src/main.js

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,32 @@ const core = require('@actions/core');
33

44
const {GITHUB_REPOSITORY, GITHUB_SERVER_URL, GITHUB_RUN_ID, GITHUB_JOB} = process.env;
55

6+
function guessPrNumber() {
7+
if ('workflow_run' === github.context.eventName) {
8+
return 'pull_request' === github.context.payload.event && github.context.payload.pull_requests[0]?.number
9+
? github.context.payload.pull_requests[0]?.number
10+
: undefined
11+
;
12+
}
13+
14+
return 'pull_request' === github.context.eventName ? github.context.payload.number : undefined;
15+
}
16+
17+
function guessCommitSha() {
18+
// "${{ ('workflow_run' == github.event_name && ('pull_request' == github.event.workflow_run.event || 'push' == github.event.workflow_run.event) && github.event.workflow_run.head_sha) || ('pull_request' == github.event_name && github.event.pull_request.head.sha) || ('push' == github.event_name && github.sha) || null }}"
19+
if ('workflow_run' === github.context.eventName) {
20+
return 'pull_request' === github.context.payload.event || 'push' === github.context.payload.event
21+
? github.context.payload.head_sha
22+
: undefined
23+
;
24+
}
25+
26+
return 'pull_request' === github.context.eventName ? github.context.payload.number : undefined;
27+
}
28+
629
async function run() {
30+
core.info('TMP DEBUG ' + JSON.stringify(github.context));throw 'plop';
731
/** INPUTS **/
8-
const commitSha = core.getInput('commit-sha', {required: true});
932
const checkName = core.getInput('name', {required: true});
1033
const githubToken = core.getInput('github-token', {required: true});
1134
const jobStatus = core.getInput('job-status', {required: true});
@@ -16,13 +39,10 @@ async function run() {
1639
'Build API params',
1740
async () => {
1841
const [repoOwner, repoName] = GITHUB_REPOSITORY.split('/');
19-
const externalId = GITHUB_RUN_ID;
42+
const externalId = 'workflow_run' === github.context.eventName ? github.context.payload.id : GITHUB_RUN_ID;
43+
const commitSha = guessCommitSha();
2044
const startedAt = (new Date()).toISOString();
21-
//${{ ( 'workflow_run' == github.event_name && 'pull_request' == github.event.workflow_run.event && github.event.workflow_run.pull_requests[0] && github.event.workflow_run.pull_requests[0].number) || ('pull_request' == github.event_name && github.event.number) || null }}
22-
const prNumber = 'workflow_run' === github.context.eventName && 'pull_request' === github.context.payload.event && github.context.payload.pull_requests[0]?.number
23-
? github.context.payload.pull_requests[0]?.number
24-
: undefined
25-
;
45+
const prNumber = guessPrNumber();
2646
const detailsUrl = GITHUB_SERVER_URL + '/' + GITHUB_REPOSITORY + '/actions/runs/' + GITHUB_RUN_ID + '/job/' + GITHUB_JOB + (undefined !== prNumber ? '?pr=' + prNumber : '');
2747
const outputTitle = 'My title';
2848
const outputSummary = 'My summary';

.github/actions/reports-group/attach-check-run-to-triggering-workflow-action/yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@
113113
dependencies:
114114
"@octokit/openapi-types" "^20.0.0"
115115

116+
"@octokit/webhooks-definitions@^3.67.3":
117+
version "3.67.3"
118+
resolved "https://registry.yarnpkg.com/@octokit/webhooks-definitions/-/webhooks-definitions-3.67.3.tgz#d2a905a90b04af8111982d0c13658a49fc4eecb9"
119+
integrity sha512-do4Z1r2OVhuI0ihJhQ8Hg+yPWnBYEBNuFNCrvtPKoYT1w81jD7pBXgGe86lYuuNirkDHb0Nxt+zt4O5GiFJfgA==
120+
116121
"@vercel/ncc@^0.38.1":
117122
version "0.38.1"
118123
resolved "https://registry.yarnpkg.com/@vercel/ncc/-/ncc-0.38.1.tgz#13f08738111e1d9e8a22fd6141f3590e54d9a60e"

0 commit comments

Comments
 (0)