33name : Release
44
55on :
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
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 {
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()
0 commit comments