3
3
name : Release
4
4
5
5
on :
6
+ workflow_dispatch :
6
7
push :
7
8
branches :
8
9
- main
@@ -51,17 +52,19 @@ jobs:
51
52
env :
52
53
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
53
54
run : |
54
- npx --offline template-oss-release-please ${{ github.ref_name }}
55
+ npx --offline template-oss-release-please ${{ github.ref_name }} ${{ github.event_name }}
55
56
- name : Post Pull Request Comment
56
57
if : steps.release.outputs.pr-number
57
58
uses : actions/github-script@v6
58
59
id : pr-comment
59
60
env :
60
61
PR_NUMBER : ${{ steps.release.outputs.pr-number }}
62
+ REF_NAME : ${{ github.ref_name }}
61
63
with :
62
64
script : |
65
+ const { REF_NAME, PR_NUMBER } = process.env
63
66
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 }
65
68
66
69
const { data: workflow } = await github.rest.actions.getWorkflowRun({ ...repo, run_id: context.runId })
67
70
70
73
const comments = await github.paginate(github.rest.issues.listComments, issue)
71
74
let commentId = comments?.find(c => c.user.login === 'github-actions[bot]' && c.body.startsWith(body))?.id
72
75
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
+
74
81
if (commentId) {
75
82
await github.rest.issues.updateComment({ ...repo, comment_id: commentId, body })
76
83
} else {
79
86
}
80
87
81
88
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 }
82
122
- name : Create Check
83
123
uses : LouisBrunner/checks-action@v1.3.1
84
124
id : check
@@ -88,12 +128,7 @@ jobs:
88
128
status : in_progress
89
129
name : Release
90
130
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 }}
97
132
98
133
update :
99
134
needs : release
@@ -142,6 +177,39 @@ jobs:
142
177
git commit --all --amend --no-edit || true
143
178
git push --force-with-lease
144
179
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 }
145
213
- name : Create Check
146
214
uses : LouisBrunner/checks-action@v1.3.1
147
215
id : check
@@ -151,12 +219,7 @@ jobs:
151
219
status : in_progress
152
220
name : Release
153
221
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 }}
160
223
- name : Conclude Check
161
224
uses : LouisBrunner/checks-action@v1.3.1
162
225
if : always()
0 commit comments