Skip to content

Commit e0c1cb1

Browse files
committed
chore: postinstall for dependabot template-oss PR
1 parent bbdf054 commit e0c1cb1

File tree

4 files changed

+149
-30
lines changed

4 files changed

+149
-30
lines changed

.github/workflows/ci-release.yml

+68-12
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/checks-action@v1.3.1
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:
@@ -94,6 +122,39 @@ jobs:
94122
run:
95123
shell: ${{ matrix.platform.shell }}
96124
steps:
125+
- name: Get Workflow Job
126+
uses: actions/github-script@v6
127+
128+
id: check-output
129+
env:
130+
JOB_NAME: "Test All"
131+
MATRIX_NAME: " - ${{ matrix.platform.name }} - ${{ matrix.node-version }}"
132+
with:
133+
script: |
134+
const { owner, repo } = context.repo
135+
136+
const { data } = await github.rest.actions.listJobsForWorkflowRun({
137+
owner,
138+
repo,
139+
run_id: context.runId,
140+
per_page: 100
141+
})
142+
143+
const jobName = process.env.JOB_NAME + process.env.MATRIX_NAME
144+
const job = data.jobs.find(j => j.name.endsWith(jobName))
145+
const jobUrl = job?.html_url
146+
147+
const shaUrl = `${context.serverUrl}/${owner}/${repo}/commit/${{ inputs.check-sha }}`
148+
149+
let summary = `This check is assosciated with ${shaUrl}\n\n`
150+
151+
if (jobUrl) {
152+
summary += `For run logs, click here: ${jobUrl}`
153+
} else {
154+
summary += `Run logs could not be found for a job with name: "${jobName}"`
155+
}
156+
157+
return { summary }
97158
- name: Create Check
98159
uses: LouisBrunner/checks-action@v1.3.1
99160
id: check
@@ -103,12 +164,7 @@ jobs:
103164
status: in_progress
104165
name: Test All - ${{ matrix.platform.name }} - ${{ matrix.node-version }}
105166
sha: ${{ inputs.check-sha }}
106-
# XXX: this does not work when using the default GITHUB_TOKEN.
107-
# Instead we post the main job url to the PR as a comment which
108-
# will link to all the other checks. To work around this we would
109-
# need to create a GitHub that would create on-demand tokens.
110-
# https://github.com/LouisBrunner/checks-action/issues/18
111-
# details_url:
167+
output: ${{ steps.check-output.outputs.result }}
112168
- name: Checkout
113169
uses: actions/checkout@v3
114170
with:

.github/workflows/post-dependabot.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
# This only sets the conventional commit prefix. This workflow can't reliably determine
6767
# what the breaking change is though. If a BREAKING CHANGE message is required then
6868
# this PR check will fail and the commit will be amended with stafftools
69-
if [[ "${{ steps.dependabot-metadata.outputs.update-type }}" == "version-update:semver-major" ]]; then
69+
if [[ "${{ steps.metadata.outputs.update-type }}" == "version-update:semver-major" ]]; then
7070
prefix='feat!'
7171
else
7272
prefix='chore!'
@@ -90,7 +90,7 @@ jobs:
9090
# and attempt to commit and push again. This is helpful because we will have a commit
9191
# with the correct prefix that we can then --amend with @npmcli/stafftools later.
9292
- name: Push All Changes Except Workflows
93-
if: steps.apply.outputs.changes && steps.push-all.outcome == 'failure'
93+
if: steps.apply.outputs.changes && steps.push.outcome == 'failure'
9494
env:
9595
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9696
run: |

.github/workflows/release.yml

+78-15
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
@@ -51,17 +52,19 @@ jobs:
5152
env:
5253
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5354
run: |
54-
npx --offline template-oss-release-please ${{ github.ref_name }}
55+
npx --offline template-oss-release-please ${{ github.ref_name }} ${{ github.event_name }}
5556
- name: Post Pull Request Comment
5657
if: steps.release.outputs.pr-number
5758
uses: actions/github-script@v6
5859
id: pr-comment
5960
env:
6061
PR_NUMBER: ${{ steps.release.outputs.pr-number }}
62+
REF_NAME: ${{ github.ref_name }}
6163
with:
6264
script: |
65+
const { REF_NAME, PR_NUMBER } = process.env
6366
const repo = { owner: context.repo.owner, repo: context.repo.repo }
64-
const issue = { ...repo, issue_number: process.env.PR_NUMBER }
67+
const issue = { ...repo, issue_number: PR_NUMBER }
6568
6669
const { data: workflow } = await github.rest.actions.getWorkflowRun({ ...repo, run_id: context.runId })
6770
@@ -70,7 +73,11 @@ jobs:
7073
const comments = await github.paginate(github.rest.issues.listComments, issue)
7174
let commentId = comments?.find(c => c.user.login === 'github-actions[bot]' && c.body.startsWith(body))?.id
7275
73-
body += `- Release workflow run: ${workflow.html_url}`
76+
body += `Release workflow run: ${workflow.html_url}\n\n#### Force CI to Rerun for This Release\n\n`
77+
body += `This PR will be updated and CI will run for every non-\`chore:\` commit that is pushed to \`main\`. `
78+
body += `To force CI to rerun, run this command:\n\n`
79+
body += `\`\`\`\ngh workflow run release.yml -r ${REF_NAME}\n\`\`\``
80+
7481
if (commentId) {
7582
await github.rest.issues.updateComment({ ...repo, comment_id: commentId, body })
7683
} else {
@@ -79,6 +86,39 @@ jobs:
7986
}
8087
8188
return commentId
89+
- name: Get Workflow Job
90+
uses: actions/github-script@v6
91+
if: steps.release.outputs.pr-number
92+
id: check-output
93+
env:
94+
JOB_NAME: "Release"
95+
MATRIX_NAME: ""
96+
with:
97+
script: |
98+
const { owner, repo } = context.repo
99+
100+
const { data } = await github.rest.actions.listJobsForWorkflowRun({
101+
owner,
102+
repo,
103+
run_id: context.runId,
104+
per_page: 100
105+
})
106+
107+
const jobName = process.env.JOB_NAME + process.env.MATRIX_NAME
108+
const job = data.jobs.find(j => j.name.endsWith(jobName))
109+
const jobUrl = job?.html_url
110+
111+
const shaUrl = `${context.serverUrl}/${owner}/${repo}/commit/${{ steps.release.outputs.pr-sha }}`
112+
113+
let summary = `This check is assosciated with ${shaUrl}\n\n`
114+
115+
if (jobUrl) {
116+
summary += `For run logs, click here: ${jobUrl}`
117+
} else {
118+
summary += `Run logs could not be found for a job with name: "${jobName}"`
119+
}
120+
121+
return { summary }
82122
- name: Create Check
83123
uses: LouisBrunner/checks-action@v1.3.1
84124
id: check
@@ -88,12 +128,7 @@ jobs:
88128
status: in_progress
89129
name: Release
90130
sha: ${{ steps.release.outputs.pr-sha }}
91-
# XXX: this does not work when using the default GITHUB_TOKEN.
92-
# Instead we post the main job url to the PR as a comment which
93-
# will link to all the other checks. To work around this we would
94-
# need to create a GitHub that would create on-demand tokens.
95-
# https://github.com/LouisBrunner/checks-action/issues/18
96-
# details_url:
131+
output: ${{ steps.check-output.outputs.result }}
97132

98133
update:
99134
needs: release
@@ -142,6 +177,39 @@ jobs:
142177
git commit --all --amend --no-edit || true
143178
git push --force-with-lease
144179
echo "::set-output name=sha::$(git rev-parse HEAD)"
180+
- name: Get Workflow Job
181+
uses: actions/github-script@v6
182+
183+
id: check-output
184+
env:
185+
JOB_NAME: "Update - Release"
186+
MATRIX_NAME: ""
187+
with:
188+
script: |
189+
const { owner, repo } = context.repo
190+
191+
const { data } = await github.rest.actions.listJobsForWorkflowRun({
192+
owner,
193+
repo,
194+
run_id: context.runId,
195+
per_page: 100
196+
})
197+
198+
const jobName = process.env.JOB_NAME + process.env.MATRIX_NAME
199+
const job = data.jobs.find(j => j.name.endsWith(jobName))
200+
const jobUrl = job?.html_url
201+
202+
const shaUrl = `${context.serverUrl}/${owner}/${repo}/commit/${{ steps.commit.outputs.sha }}`
203+
204+
let summary = `This check is assosciated with ${shaUrl}\n\n`
205+
206+
if (jobUrl) {
207+
summary += `For run logs, click here: ${jobUrl}`
208+
} else {
209+
summary += `Run logs could not be found for a job with name: "${jobName}"`
210+
}
211+
212+
return { summary }
145213
- name: Create Check
146214
uses: LouisBrunner/checks-action@v1.3.1
147215
id: check
@@ -151,12 +219,7 @@ jobs:
151219
status: in_progress
152220
name: Release
153221
sha: ${{ steps.commit.outputs.sha }}
154-
# XXX: this does not work when using the default GITHUB_TOKEN.
155-
# Instead we post the main job url to the PR as a comment which
156-
# will link to all the other checks. To work around this we would
157-
# need to create a GitHub that would create on-demand tokens.
158-
# https://github.com/LouisBrunner/checks-action/issues/18
159-
# details_url:
222+
output: ${{ steps.check-output.outputs.result }}
160223
- name: Conclude Check
161224
uses: LouisBrunner/checks-action@v1.3.1
162225
if: always()

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
},
3434
"templateOSS": {
3535
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
36-
"version": "4.5.1"
36+
"version": "4.6.1"
3737
},
3838
"tap": {
3939
"nyc-arg": [

0 commit comments

Comments
 (0)