fix(GHA): make the comments slightly more actionable (#66626)

This commit is contained in:
Mrugesh Mohapatra
2026-03-26 19:49:55 +05:30
committed by GitHub
parent 22b6179064
commit ae3faf71b5
2 changed files with 32 additions and 7 deletions
@@ -26,6 +26,7 @@ module.exports = async ({ github, context, isAllowListed }) => {
if (isAllowListed === 'true') return;
const body = (context.payload.pull_request.body || '').toLowerCase();
const action = context.payload.action;
// The template must be present and the first 3 checkboxes must be
// ticked. The last checkbox (tested locally) is acceptable to leave
@@ -45,7 +46,25 @@ module.exports = async ({ github, context, isAllowListed }) => {
normalizedBody.includes(`[x] ${item}`)
);
if (templatePresent && allRequiredTicked) return;
if (templatePresent && allRequiredTicked) {
// On edit, remove the deprioritized label if the check now passes.
if (action === 'edited') {
try {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
name: 'deprioritized'
});
} catch {
// Label may not exist — ignore.
}
}
return;
}
// On edit, don't re-comment — the original comment is already there.
if (action === 'edited') return;
await github.rest.issues.addLabels({
owner: context.repo.owner,
@@ -64,7 +83,13 @@ module.exports = async ({ github, context, isAllowListed }) => {
'',
'Thank you for the contribution.',
'',
"Please add back the following template to the PR description and complete the checklist items. We won't be able to review this PR until then.",
'The automated checks found a few issues with the PR. Currently the PR description is missing the required checklist or some of its items are not completed:',
'',
'1. The `Checklist:` heading is present in the PR description.',
'2. The checkbox items are ticked (changed from `[ ]` to `[x]`).',
'3. You have actually completed the items in the checklist.',
'',
'Please edit your PR description to include the following template with the checklist items completed.',
'',
TEMPLATE_BLOCK
].join('\n') + FOOTER
+5 -5
View File
@@ -2,7 +2,7 @@ name: GitHub - PR Contribution Guidelines
on:
pull_request_target:
types: [opened, reopened]
types: [opened, reopened, edited]
jobs:
# Ensures PR commits were not added via the GitHub Web UI, which typically indicates
@@ -31,7 +31,7 @@ jobs:
- name: Check if commits are made on GitHub Web UI
id: check-commits
if: steps.pr_author.outputs.is_allow_listed == 'false'
if: steps.pr_author.outputs.is_allow_listed == 'false' && github.event.action != 'edited'
env:
HEAD_REF: ${{ github.head_ref }}
run: |
@@ -50,7 +50,7 @@ jobs:
- name: Add comment on PR if commits are made on GitHub Web UI
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
if: steps.pr_author.outputs.is_allow_listed == 'false' && env.IS_GITHUB_COMMIT == 'true'
if: steps.pr_author.outputs.is_allow_listed == 'false' && env.IS_GITHUB_COMMIT == 'true' && github.event.action != 'edited'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
@@ -81,7 +81,7 @@ jobs:
name: Fix PR Title
runs-on: ubuntu-24.04
needs: no-web-commits
if: needs.no-web-commits.result == 'success'
if: needs.no-web-commits.result == 'success' && github.event.action != 'edited'
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
@@ -122,7 +122,7 @@ jobs:
name: Check Linked Issue
runs-on: ubuntu-24.04
needs: no-web-commits
if: needs.no-web-commits.result == 'success'
if: needs.no-web-commits.result == 'success' && github.event.action != 'edited'
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with: