diff --git a/.github/workflows/check_release_notes.yml b/.github/workflows/check_release_notes.yml index 34a19b198c5..cc29e6c9929 100644 --- a/.github/workflows/check_release_notes.yml +++ b/.github/workflows/check_release_notes.yml @@ -8,7 +8,7 @@ on: permissions: contents: read issues: write - pull-requests: read + pull-requests: write concurrency: group: release-notes-${{ github.event.pull_request.number }} cancel-in-progress: true @@ -17,7 +17,7 @@ jobs: permissions: contents: read issues: write - pull-requests: read + pull-requests: write env: GH_TOKEN: ${{ github.token }} PR_AUTHOR: ${{ github.event.pull_request.user.login }} @@ -314,29 +314,36 @@ jobs: github-token: ${{ github.token }} script: | const marker = ''; - const comments = await github.paginate(github.rest.issues.listComments, { - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.issue.number, - per_page: 100 - }); - const existing = comments.find(comment => - comment.user?.login === 'github-actions[bot]' && comment.body?.includes(marker)); - - if (existing) { - const comment = await github.rest.issues.updateComment({ + // Posting the status comment is best-effort and must never fail the check: + // the release-notes gate is enforced by the previous step's exit code. + try { + const comments = await github.paginate(github.rest.issues.listComments, { + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + per_page: 100 + }); + const existing = comments.find(comment => + comment.user?.login === 'github-actions[bot]' && comment.body?.includes(marker)); + + if (existing) { + const comment = await github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: existing.id, + body: process.env.COMMENT_BODY + }); + return comment.data.id; + } + + const comment = await github.rest.issues.createComment({ + issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, - comment_id: existing.id, body: process.env.COMMENT_BODY }); return comment.data.id; + } catch (error) { + core.warning(`Unable to post the release-notes status comment: ${error.message}`); + return ''; } - - const comment = await github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: process.env.COMMENT_BODY - }); - return comment.data.id;