3
3
name : Release
4
4
5
5
on :
6
+ workflow_dispatch :
6
7
push :
7
8
branches :
8
9
- main
@@ -48,17 +49,19 @@ jobs:
48
49
env :
49
50
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
50
51
run : |
51
- npx --offline template-oss-release-please ${{ github.ref_name }}
52
+ npx --offline template-oss-release-please ${{ github.ref_name }} ${{ github.event_name }}
52
53
- name : Post Pull Request Comment
53
54
if : steps.release.outputs.pr-number
54
55
uses : actions/github-script@v6
55
56
id : pr-comment
56
57
env :
57
58
PR_NUMBER : ${{ steps.release.outputs.pr-number }}
59
+ REF_NAME : ${{ github.ref_name }}
58
60
with :
59
61
script : |
62
+ const { REF_NAME, PR_NUMBER } = process.env
60
63
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 }
62
65
63
66
const { data: workflow } = await github.rest.actions.getWorkflowRun({ ...repo, run_id: context.runId })
64
67
67
70
const comments = await github.paginate(github.rest.issues.listComments, issue)
68
71
let commentId = comments?.find(c => c.user.login === 'github-actions[bot]' && c.body.startsWith(body))?.id
69
72
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
+
71
78
if (commentId) {
72
79
await github.rest.issues.updateComment({ ...repo, comment_id: commentId, body })
73
80
} else {
76
83
}
77
84
78
85
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 }
79
119
- name : Create Check
80
120
uses :
LouisBrunner/[email protected]
81
121
id : check
@@ -85,12 +125,7 @@ jobs:
85
125
status : in_progress
86
126
name : Release
87
127
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 }}
94
129
95
130
update :
96
131
needs : release
@@ -136,6 +171,39 @@ jobs:
136
171
git commit --all --amend --no-edit || true
137
172
git push --force-with-lease
138
173
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 }
139
207
- name : Create Check
140
208
uses :
LouisBrunner/[email protected]
141
209
id : check
@@ -145,12 +213,7 @@ jobs:
145
213
status : in_progress
146
214
name : Release
147
215
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 }}
154
217
- name : Conclude Check
155
218
uses :
LouisBrunner/[email protected]
156
219
if : always()
0 commit comments