@@ -4,6 +4,10 @@ name: Release
44
55on :
66 workflow_dispatch :
7+ inputs :
8+ release-pr :
9+ description : a release PR number to rerun release jobs on
10+ type : string
711 push :
812 branches :
913 - main
5357 env :
5458 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
5559 run : |
56- npx --offline template-oss-release-please ${{ github.ref_name }} ${{ github.event_name }}
60+ npx --offline template-oss-release-please " ${{ github.ref_name }}" " ${{ inputs.release-pr }}"
5761 - name : Post Pull Request Comment
5862 if : steps.release.outputs.pr-number
5963 uses : actions/github-script@v6
7680 body += `Release workflow run: ${workflow.html_url}\n\n#### Force CI to Update This Release\n\n`
7781 body += `This PR will be updated and CI will run for every non-\`chore:\` commit that is pushed to \`main\`. `
7882 body += `To force CI to update this PR, run this command:\n\n`
79- body += `\`\`\`\ngh workflow run release.yml -r ${REF_NAME} -R ${owner}/${repo}\n\`\`\``
83+ body += `\`\`\`\ngh workflow run release.yml -r ${REF_NAME} -R ${owner}/${repo} -f release-pr=${issue_number} \n\`\`\``
8084
8185 if (commentId) {
8286 await github.rest.issues.updateComment({ owner, repo, comment_id: commentId, body })
@@ -291,14 +295,17 @@ jobs:
291295 }
292296
293297 const comments = await github.paginate(github.rest.issues.listComments, { owner, repo, issue_number })
294- const releaseComments = comments.filter(c => c.user.login === 'github-actions[bot]' && c.body.includes('Release is at'))
298+ .then(cs => cs.map(c => ({ id: c.id, login: c.user.login, body: c.body })))
299+ console.log(`Found comments: ${JSON.stringify(comments, null, 2)}`)
300+ const releaseComments = comments.filter(c => c.login === 'github-actions[bot]' && c.body.includes('Release is at'))
295301
296302 for (const comment of releaseComments) {
303+ console.log(`Release comment: ${JSON.stringify(comment, null, 2)}`)
297304 await github.rest.issues.deleteComment({ owner, repo, comment_id: comment.id })
298305 }
299306
300307 const runUrl = `https://github.com/${owner}/${repo}/actions/runs/${runId}`
301- await github.rest.issues.createComment({
308+ await github.rest.issues.createComment({
302309 owner,
303310 repo,
304311 issue_number,
@@ -378,10 +385,14 @@ jobs:
378385 with :
379386 script : |
380387 const { PR_NUMBER: issue_number, RESULT } = process.env
381- const { repo: { owner, repo } } = context
388+ const { runId, repo: { owner, repo } } = context
382389
383390 const comments = await github.paginate(github.rest.issues.listComments, { owner, repo, issue_number })
384- const updateComment = comments.find(c => c.user.login === 'github-actions[bot]' && c.body.startsWith('## Release Workflow\n\n'))
391+ const updateComment = comments.find(c =>
392+ c.user.login === 'github-actions[bot]' &&
393+ c.body.startsWith('## Release Workflow\n\n') &&
394+ c.body.includes(runId)
395+ )
385396
386397 if (updateComment) {
387398 console.log('Found comment to update:', JSON.stringify(updateComment, null, 2))
0 commit comments