|
8 | 8 | permissions: |
9 | 9 | contents: read |
10 | 10 | issues: write |
11 | | - pull-requests: read |
| 11 | + pull-requests: write |
12 | 12 | concurrency: |
13 | 13 | group: release-notes-${{ github.event.pull_request.number }} |
14 | 14 | cancel-in-progress: true |
|
17 | 17 | permissions: |
18 | 18 | contents: read |
19 | 19 | issues: write |
20 | | - pull-requests: read |
| 20 | + pull-requests: write |
21 | 21 | env: |
22 | 22 | GH_TOKEN: ${{ github.token }} |
23 | 23 | PR_AUTHOR: ${{ github.event.pull_request.user.login }} |
@@ -305,38 +305,51 @@ jobs: |
305 | 305 | exit 1 |
306 | 306 | fi |
307 | 307 | # Keep one bot comment current without evaluating pull request content as JavaScript. |
| 308 | + # Posting the informational comment is best-effort and must never fail the check: |
| 309 | + # this job runs via pull_request_target, and the Actions GITHUB_TOKEN is not always |
| 310 | + # permitted to create a new issue comment (the comment API can return HTTP 403 |
| 311 | + # "Resource not accessible by integration"), even though release-notes validation |
| 312 | + # above has already succeeded. |
308 | 313 | - name: Create or update comment |
309 | 314 | if: ${{ (success() || failure()) && steps.release_notes_changes.outputs.release-notes-check-message != '' }} |
| 315 | + continue-on-error: true |
310 | 316 | uses: actions/github-script@v9 |
311 | 317 | env: |
312 | 318 | COMMENT_BODY: ${{ steps.release_notes_changes.outputs.release-notes-check-message }} |
313 | 319 | with: |
314 | 320 | github-token: ${{ github.token }} |
315 | 321 | script: | |
316 | 322 | const marker = '<!-- DO_NOT_REMOVE: release_notes_check -->'; |
317 | | - const comments = await github.paginate(github.rest.issues.listComments, { |
318 | | - owner: context.repo.owner, |
319 | | - repo: context.repo.repo, |
320 | | - issue_number: context.issue.number, |
321 | | - per_page: 100 |
322 | | - }); |
323 | | - const existing = comments.find(comment => |
324 | | - comment.user?.login === 'github-actions[bot]' && comment.body?.includes(marker)); |
325 | | -
|
326 | | - if (existing) { |
327 | | - const comment = await github.rest.issues.updateComment({ |
| 323 | + try { |
| 324 | + const comments = await github.paginate(github.rest.issues.listComments, { |
| 325 | + owner: context.repo.owner, |
| 326 | + repo: context.repo.repo, |
| 327 | + issue_number: context.issue.number, |
| 328 | + per_page: 100 |
| 329 | + }); |
| 330 | + const existing = comments.find(comment => |
| 331 | + comment.user?.login === 'github-actions[bot]' && comment.body?.includes(marker)); |
| 332 | +
|
| 333 | + if (existing) { |
| 334 | + const comment = await github.rest.issues.updateComment({ |
| 335 | + owner: context.repo.owner, |
| 336 | + repo: context.repo.repo, |
| 337 | + comment_id: existing.id, |
| 338 | + body: process.env.COMMENT_BODY |
| 339 | + }); |
| 340 | + return comment.data.id; |
| 341 | + } |
| 342 | +
|
| 343 | + const comment = await github.rest.issues.createComment({ |
| 344 | + issue_number: context.issue.number, |
328 | 345 | owner: context.repo.owner, |
329 | 346 | repo: context.repo.repo, |
330 | | - comment_id: existing.id, |
331 | 347 | body: process.env.COMMENT_BODY |
332 | 348 | }); |
333 | 349 | return comment.data.id; |
| 350 | + } catch (error) { |
| 351 | + // The comment is informational only. The release-notes verdict is enforced by the |
| 352 | + // "Check for release notes changes" step, so never fail the job if posting fails |
| 353 | + // (e.g. a read-only token on some pull requests). |
| 354 | + core.warning(`Unable to post release-notes comment: ${error.message}`); |
334 | 355 | } |
335 | | -
|
336 | | - const comment = await github.rest.issues.createComment({ |
337 | | - issue_number: context.issue.number, |
338 | | - owner: context.repo.owner, |
339 | | - repo: context.repo.repo, |
340 | | - body: process.env.COMMENT_BODY |
341 | | - }); |
342 | | - return comment.data.id; |
|
0 commit comments