Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 35 additions & 22 deletions .github/workflows/check_release_notes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }}
Expand Down Expand Up @@ -305,38 +305,51 @@ jobs:
exit 1
fi
# Keep one bot comment current without evaluating pull request content as JavaScript.
# Posting the informational comment is best-effort and must never fail the check:
# this job runs via pull_request_target, and the Actions GITHUB_TOKEN is not always
# permitted to create a new issue comment (the comment API can return HTTP 403
# "Resource not accessible by integration"), even though release-notes validation
# above has already succeeded.
- name: Create or update comment
if: ${{ (success() || failure()) && steps.release_notes_changes.outputs.release-notes-check-message != '' }}
continue-on-error: true
uses: actions/github-script@v9
env:
COMMENT_BODY: ${{ steps.release_notes_changes.outputs.release-notes-check-message }}
with:
github-token: ${{ github.token }}
script: |
const marker = '<!-- DO_NOT_REMOVE: release_notes_check -->';
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({
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) {
// The comment is informational only. The release-notes verdict is enforced by the
// "Check for release notes changes" step, so never fail the job if posting fails
// (e.g. a read-only token on some pull requests).
core.warning(`Unable to post release-notes comment: ${error.message}`);
}

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;
Loading