Skip to content

Commit 38dc7f6

Browse files
committed
1 parent 58065bc commit 38dc7f6

File tree

18 files changed

+388
-128
lines changed

18 files changed

+388
-128
lines changed

.github/workflows/ci-release.yml

Lines changed: 102 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,39 @@ jobs:
2121
run:
2222
shell: bash
2323
steps:
24+
- name: Get Workflow Job
25+
uses: actions/github-script@v6
26+
27+
id: check-output
28+
env:
29+
JOB_NAME: "Lint All"
30+
MATRIX_NAME: ""
31+
with:
32+
script: |
33+
const { owner, repo } = context.repo
34+
35+
const { data } = await github.rest.actions.listJobsForWorkflowRun({
36+
owner,
37+
repo,
38+
run_id: context.runId,
39+
per_page: 100
40+
})
41+
42+
const jobName = process.env.JOB_NAME + process.env.MATRIX_NAME
43+
const job = data.jobs.find(j => j.name.endsWith(jobName))
44+
const jobUrl = job?.html_url
45+
46+
const shaUrl = `${context.serverUrl}/${owner}/${repo}/commit/${{ inputs.check-sha }}`
47+
48+
let summary = `This check is assosciated with ${shaUrl}\n\n`
49+
50+
if (jobUrl) {
51+
summary += `For run logs, click here: ${jobUrl}`
52+
} else {
53+
summary += `Run logs could not be found for a job with name: "${jobName}"`
54+
}
55+
56+
return { summary }
2457
- name: Create Check
2558
uses: LouisBrunner/[email protected]
2659
id: check
@@ -30,12 +63,7 @@ jobs:
3063
status: in_progress
3164
name: Lint All
3265
sha: ${{ inputs.check-sha }}
33-
# XXX: this does not work when using the default GITHUB_TOKEN.
34-
# Instead we post the main job url to the PR as a comment which
35-
# will link to all the other checks. To work around this we would
36-
# need to create a GitHub that would create on-demand tokens.
37-
# https://github.com/LouisBrunner/checks-action/issues/18
38-
# details_url:
66+
output: ${{ steps.check-output.outputs.result }}
3967
- name: Checkout
4068
uses: actions/checkout@v3
4169
with:
@@ -91,6 +119,39 @@ jobs:
91119
run:
92120
shell: ${{ matrix.platform.shell }}
93121
steps:
122+
- name: Get Workflow Job
123+
uses: actions/github-script@v6
124+
125+
id: check-output
126+
env:
127+
JOB_NAME: "Test All"
128+
MATRIX_NAME: " - ${{ matrix.platform.name }} - ${{ matrix.node-version }}"
129+
with:
130+
script: |
131+
const { owner, repo } = context.repo
132+
133+
const { data } = await github.rest.actions.listJobsForWorkflowRun({
134+
owner,
135+
repo,
136+
run_id: context.runId,
137+
per_page: 100
138+
})
139+
140+
const jobName = process.env.JOB_NAME + process.env.MATRIX_NAME
141+
const job = data.jobs.find(j => j.name.endsWith(jobName))
142+
const jobUrl = job?.html_url
143+
144+
const shaUrl = `${context.serverUrl}/${owner}/${repo}/commit/${{ inputs.check-sha }}`
145+
146+
let summary = `This check is assosciated with ${shaUrl}\n\n`
147+
148+
if (jobUrl) {
149+
summary += `For run logs, click here: ${jobUrl}`
150+
} else {
151+
summary += `Run logs could not be found for a job with name: "${jobName}"`
152+
}
153+
154+
return { summary }
94155
- name: Create Check
95156
uses: LouisBrunner/[email protected]
96157
id: check
@@ -100,12 +161,7 @@ jobs:
100161
status: in_progress
101162
name: Test All - ${{ matrix.platform.name }} - ${{ matrix.node-version }}
102163
sha: ${{ inputs.check-sha }}
103-
# XXX: this does not work when using the default GITHUB_TOKEN.
104-
# Instead we post the main job url to the PR as a comment which
105-
# will link to all the other checks. To work around this we would
106-
# need to create a GitHub that would create on-demand tokens.
107-
# https://github.com/LouisBrunner/checks-action/issues/18
108-
# details_url:
164+
output: ${{ steps.check-output.outputs.result }}
109165
- name: Checkout
110166
uses: actions/checkout@v3
111167
with:
@@ -166,6 +222,39 @@ jobs:
166222
run:
167223
shell: ${{ matrix.platform.shell }}
168224
steps:
225+
- name: Get Workflow Job
226+
uses: actions/github-script@v6
227+
228+
id: check-output
229+
env:
230+
JOB_NAME: "Smoke Publish"
231+
MATRIX_NAME: " - ${{ matrix.platform.name }} - ${{ matrix.node-version }}"
232+
with:
233+
script: |
234+
const { owner, repo } = context.repo
235+
236+
const { data } = await github.rest.actions.listJobsForWorkflowRun({
237+
owner,
238+
repo,
239+
run_id: context.runId,
240+
per_page: 100
241+
})
242+
243+
const jobName = process.env.JOB_NAME + process.env.MATRIX_NAME
244+
const job = data.jobs.find(j => j.name.endsWith(jobName))
245+
const jobUrl = job?.html_url
246+
247+
const shaUrl = `${context.serverUrl}/${owner}/${repo}/commit/${{ inputs.check-sha }}`
248+
249+
let summary = `This check is assosciated with ${shaUrl}\n\n`
250+
251+
if (jobUrl) {
252+
summary += `For run logs, click here: ${jobUrl}`
253+
} else {
254+
summary += `Run logs could not be found for a job with name: "${jobName}"`
255+
}
256+
257+
return { summary }
169258
- name: Create Check
170259
uses: LouisBrunner/[email protected]
171260
id: check
@@ -175,12 +264,7 @@ jobs:
175264
status: in_progress
176265
name: Smoke Publish - ${{ matrix.platform.name }} - ${{ matrix.node-version }}
177266
sha: ${{ inputs.check-sha }}
178-
# XXX: this does not work when using the default GITHUB_TOKEN.
179-
# Instead we post the main job url to the PR as a comment which
180-
# will link to all the other checks. To work around this we would
181-
# need to create a GitHub that would create on-demand tokens.
182-
# https://github.com/LouisBrunner/checks-action/issues/18
183-
# details_url:
267+
output: ${{ steps.check-output.outputs.result }}
184268
- name: Checkout
185269
uses: actions/checkout@v3
186270
with:

.github/workflows/release.yml

Lines changed: 78 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
name: Release
44

55
on:
6+
workflow_dispatch:
67
push:
78
branches:
89
- main
@@ -48,17 +49,19 @@ jobs:
4849
env:
4950
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5051
run: |
51-
npx --offline template-oss-release-please ${{ github.ref_name }}
52+
npx --offline template-oss-release-please ${{ github.ref_name }} ${{ github.event_name }}
5253
- name: Post Pull Request Comment
5354
if: steps.release.outputs.pr-number
5455
uses: actions/github-script@v6
5556
id: pr-comment
5657
env:
5758
PR_NUMBER: ${{ steps.release.outputs.pr-number }}
59+
REF_NAME: ${{ github.ref_name }}
5860
with:
5961
script: |
62+
const { REF_NAME, PR_NUMBER } = process.env
6063
const repo = { owner: context.repo.owner, repo: context.repo.repo }
61-
const issue = { ...repo, issue_number: process.env.PR_NUMBER }
64+
const issue = { ...repo, issue_number: PR_NUMBER }
6265
6366
const { data: workflow } = await github.rest.actions.getWorkflowRun({ ...repo, run_id: context.runId })
6467
@@ -67,7 +70,11 @@ jobs:
6770
const comments = await github.paginate(github.rest.issues.listComments, issue)
6871
let commentId = comments?.find(c => c.user.login === 'github-actions[bot]' && c.body.startsWith(body))?.id
6972
70-
body += `- Release workflow run: ${workflow.html_url}`
73+
body += `Release workflow run: ${workflow.html_url}\n\n#### Force CI to Rerun for This Release\n\n`
74+
body += `This PR will be updated and CI will run for every non-\`chore:\` commit that is pushed to \`main\`. `
75+
body += `To force CI to rerun, run this command:\n\n`
76+
body += `\`\`\`\ngh workflow run release.yml -r ${REF_NAME}\n\`\`\``
77+
7178
if (commentId) {
7279
await github.rest.issues.updateComment({ ...repo, comment_id: commentId, body })
7380
} else {
@@ -76,6 +83,39 @@ jobs:
7683
}
7784
7885
return commentId
86+
- name: Get Workflow Job
87+
uses: actions/github-script@v6
88+
if: steps.release.outputs.pr-number
89+
id: check-output
90+
env:
91+
JOB_NAME: "Release"
92+
MATRIX_NAME: ""
93+
with:
94+
script: |
95+
const { owner, repo } = context.repo
96+
97+
const { data } = await github.rest.actions.listJobsForWorkflowRun({
98+
owner,
99+
repo,
100+
run_id: context.runId,
101+
per_page: 100
102+
})
103+
104+
const jobName = process.env.JOB_NAME + process.env.MATRIX_NAME
105+
const job = data.jobs.find(j => j.name.endsWith(jobName))
106+
const jobUrl = job?.html_url
107+
108+
const shaUrl = `${context.serverUrl}/${owner}/${repo}/commit/${{ steps.release.outputs.pr-sha }}`
109+
110+
let summary = `This check is assosciated with ${shaUrl}\n\n`
111+
112+
if (jobUrl) {
113+
summary += `For run logs, click here: ${jobUrl}`
114+
} else {
115+
summary += `Run logs could not be found for a job with name: "${jobName}"`
116+
}
117+
118+
return { summary }
79119
- name: Create Check
80120
uses: LouisBrunner/[email protected]
81121
id: check
@@ -85,12 +125,7 @@ jobs:
85125
status: in_progress
86126
name: Release
87127
sha: ${{ steps.release.outputs.pr-sha }}
88-
# XXX: this does not work when using the default GITHUB_TOKEN.
89-
# Instead we post the main job url to the PR as a comment which
90-
# will link to all the other checks. To work around this we would
91-
# need to create a GitHub that would create on-demand tokens.
92-
# https://github.com/LouisBrunner/checks-action/issues/18
93-
# details_url:
128+
output: ${{ steps.check-output.outputs.result }}
94129

95130
update:
96131
needs: release
@@ -136,6 +171,39 @@ jobs:
136171
git commit --all --amend --no-edit || true
137172
git push --force-with-lease
138173
echo "::set-output name=sha::$(git rev-parse HEAD)"
174+
- name: Get Workflow Job
175+
uses: actions/github-script@v6
176+
177+
id: check-output
178+
env:
179+
JOB_NAME: "Update - Release"
180+
MATRIX_NAME: ""
181+
with:
182+
script: |
183+
const { owner, repo } = context.repo
184+
185+
const { data } = await github.rest.actions.listJobsForWorkflowRun({
186+
owner,
187+
repo,
188+
run_id: context.runId,
189+
per_page: 100
190+
})
191+
192+
const jobName = process.env.JOB_NAME + process.env.MATRIX_NAME
193+
const job = data.jobs.find(j => j.name.endsWith(jobName))
194+
const jobUrl = job?.html_url
195+
196+
const shaUrl = `${context.serverUrl}/${owner}/${repo}/commit/${{ steps.commit.outputs.sha }}`
197+
198+
let summary = `This check is assosciated with ${shaUrl}\n\n`
199+
200+
if (jobUrl) {
201+
summary += `For run logs, click here: ${jobUrl}`
202+
} else {
203+
summary += `Run logs could not be found for a job with name: "${jobName}"`
204+
}
205+
206+
return { summary }
139207
- name: Create Check
140208
uses: LouisBrunner/[email protected]
141209
id: check
@@ -145,12 +213,7 @@ jobs:
145213
status: in_progress
146214
name: Release
147215
sha: ${{ steps.commit.outputs.sha }}
148-
# XXX: this does not work when using the default GITHUB_TOKEN.
149-
# Instead we post the main job url to the PR as a comment which
150-
# will link to all the other checks. To work around this we would
151-
# need to create a GitHub that would create on-demand tokens.
152-
# https://github.com/LouisBrunner/checks-action/issues/18
153-
# details_url:
216+
output: ${{ steps.check-output.outputs.result }}
154217
- name: Conclude Check
155218
uses: LouisBrunner/[email protected]
156219
if: always()

docs/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
"yaml": "^2.1.3"
3333
},
3434
"devDependencies": {
35-
"@npmcli/eslint-config": "^3.1.0",
36-
"@npmcli/template-oss": "4.5.1",
35+
"@npmcli/eslint-config": "^4.0.0",
36+
"@npmcli/template-oss": "4.6.1",
3737
"tap": "^16.0.1"
3838
},
3939
"author": "GitHub Inc.",
@@ -56,7 +56,7 @@
5656
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
5757
"ciVersions": "latest",
5858
"engines": "^14.17.0 || ^16.13.0 || >=18.0.0",
59-
"version": "4.5.1",
59+
"version": "4.6.1",
6060
"content": "../scripts/template-oss/index.js"
6161
}
6262
}

0 commit comments

Comments
 (0)