Skip to content

Commit f142699

Browse files
committed
Fix and improve
1 parent 5e38c81 commit f142699

File tree

6 files changed

+20
-10
lines changed

6 files changed

+20
-10
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
@@ -1,15 +1,15 @@
11
name: TODO
22
description: TODO
33
inputs:
4-
name:
5-
description: Status check name
6-
required: true
74
github-token:
85
description: Github Authentication token used to create the check through GitHub API
96
required: true
107
job-status:
118
description: Job check status
129
required: true
10+
name:
11+
description: Status check name. Default to current job name
12+
required: false
1313

1414
outputs:
1515
check-run-id:

.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/src/main.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ function guessTriggeringRunId() {
5555
return github.context.runId.toString();
5656
}
5757

58+
/**
59+
* @param octokit
60+
* @param owner
61+
* @param repo
62+
* @param runId
63+
* @returns {Promise<Record<string, any>|undefined>}
64+
*/
5865
async function guessCurrentJob(octokit, owner, repo, runId) {
5966
const jobList = await getWorkflowJobsForRunId(octokit, owner, repo, runId);
6067
core.info('TMP DEBUG jobsForCurrentWorkflow=' + JSON.stringify(jobList));
@@ -86,9 +93,9 @@ async function getWorkflowJobsForRunId(octokit, owner, repo, runId) {
8693

8794
async function run() {
8895
/** INPUTS **/
89-
const checkName = core.getInput('name', {required: true});
9096
const githubToken = core.getInput('github-token', {required: true});
9197
const jobStatus = core.getInput('job-status', {required: true});
98+
const checkName = core.getInput('name');
9299

93100
const isSuccessfulJobAsOfNow = 'success' === jobStatus;
94101
const octokit = github.getOctokit(githubToken);
@@ -122,10 +129,15 @@ async function run() {
122129
const currentWorkflowName = github.context.workflow;
123130
const outputTitle = '🔔 ' + currentWorkflowName;
124131
const currentWorkflowUrl = github.context.serverUrl + '/' + GITHUB_REPOSITORY + '/actions/runs/' + github.context.runId.toString() + (undefined !== prNumber ? '?pr=' + prNumber : '');
125-
const outputSummary = '🪢 Check added by <a href="' + currentWorkflowUrl + '" target="blank">**' + currentWorkflowName + '** workflow</a>';
132+
const outputSummary = '🪢 Check added by <a href="' + currentWorkflowUrl + '" target="blank">**' + currentWorkflowName + '** workflow</a>'
133+
+ (currentJob ? ' (<a href="' + currentJob.html_url + '" target="blank">**' + currentJob.name + '**</a>)' : '')
134+
;
135+
if (!checkName && !currentJob) {
136+
core.setFailed('Unable to guess the current job name, you must specify the check name !');
137+
}
126138

127139
return {
128-
name: checkName,
140+
name: !checkName ? currentJob.name : checkName,
129141
head_sha: commitSha,
130142
//details_url: detailsUrl,
131143
external_id: triggeringWorkflowRunId?.toString(),

.github/workflows/codacy-upload-from-artifacts.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ jobs:
4747

4848
- uses: ./custom-action-repo/.github/actions/reports-group/attach-check-run-to-triggering-workflow-action
4949
with:
50-
name: "Codacy / Upload all reports"
5150
github-token: ${{ github.token }}
5251
job-status: ${{ job.status }}
5352

.github/workflows/codecov-upload-from-artifacts.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ jobs:
3939

4040
- uses: ./custom-action-repo/.github/actions/reports-group/attach-check-run-to-triggering-workflow-action
4141
with:
42-
name: "Codecov / 📮 🗃️ Prepare uploads"
4342
github-token: ${{ github.token }}
4443
job-status: ${{ job.status }}
4544

0 commit comments

Comments
 (0)