Skip to content

Update nav: CTA button and logo link #1587

Update nav: CTA button and logo link

Update nav: CTA button and logo link #1587

name: git-bounce
on:
pull_request:
types: [opened, ready_for_review]
concurrency:
group: git-bounce-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
check-checklist:
name: Verify PR Checklist
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Check PR template and checkboxes
uses: actions/github-script@v7
with:
script: |
const prBody = context.payload.pull_request.body || '';
const prNumber = context.payload.pull_request.number;
const prUrl = context.payload.pull_request.html_url;
// Required checkboxes from the PR template
const requiredItems = [
'This is ready for review',
'I have reviewed my changes',
'I have confirmed the content is technically accurate',
'I have tested any code that is added or updated',
'I have confirmed the content is free of typos or grammar errors',
'I have verified all images and videos are clear and match production',
'This references a feature that is public'
];
const commentMarker = '<!-- git-bounce-bot -->';
let warningMessage = '';
let hasWarning = false;
// Check for required sections (must match .github/pull_request_template.md)
const requiredSections = [
'## Describe your changes',
'## Affected pages',
'## Related Issues',
'## Checklist before requesting a review',
];
const missingStructure = requiredSections
.filter((heading) => !prBody.includes(heading))
.map((heading) => `"${heading}"`);
if (missingStructure.length > 0) {
warningMessage = `**PR is missing required template sections:**\n\n${missingStructure.join('\n')}\n\nPlease use the PR template.`;
hasWarning = true;
} else {
// Check that all required checklist items exist and are checked
const missingItems = [];
const uncheckedItems = [];
for (const item of requiredItems) {
const uncheckedPattern = new RegExp(`- \\[ \\].*${item.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`, 'i');
const checkedPattern = new RegExp(`- \\[x\\].*${item.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`, 'i');
const isUnchecked = uncheckedPattern.test(prBody);
const isChecked = checkedPattern.test(prBody);
if (!isUnchecked && !isChecked) {
missingItems.push(item);
} else if (isUnchecked) {
uncheckedItems.push(item);
}
}
if (missingItems.length > 0) {
warningMessage = `**PR is missing required checklist items.** Please do not delete items from the PR template:\n\n${missingItems.map(i => `- ${i}`).join('\n')}`;
hasWarning = true;
} else if (uncheckedItems.length > 0) {
warningMessage = `**Please complete all checklist items in [the PR description](${prUrl}) before requesting review.**\n\nUnchecked items:\n${uncheckedItems.map(i => `- ${i}`).join('\n')}\n\n> **Tip:** If an item isn't relevant to your PR, mark it as checked and add "n/a" next to it.`;
hasWarning = true;
}
}
// Build comment body
let commentBody;
if (hasWarning) {
commentBody = `${commentMarker}\n## ⚠️ Checklist Incomplete\n\n${warningMessage}`;
} else {
commentBody = `${commentMarker}\n## ✅ Checklist Complete\n\nThank you for taking the time to properly review your PR! All checklist items are complete.`;
}
// Get all comments on the PR
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber
});
// Delete ALL existing bot comments (both old and new markers)
const oldMarker = '<!-- pr-checklist-bot -->';
for (const comment of comments) {
if (comment.body && (comment.body.includes(commentMarker) || comment.body.includes(oldMarker))) {
await github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: comment.id
});
}
}
// Create fresh comment
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: commentBody
});
if (hasWarning) {
core.warning(warningMessage.replace(/\*\*/g, '').replace(/\n/g, ' '));
}
console.log(hasWarning ? 'Checklist incomplete - warning posted' : 'All checklist items complete!');