Skip to content

feat: Nora settings injection #103

feat: Nora settings injection

feat: Nora settings injection #103

name: PR Checklist Verification
on:
pull_request_target:
types: [opened, reopened, edited, synchronize]
concurrency:
group: pr-checklist-verification-${{ github.event.pull_request.number }}
cancel-in-progress: false
jobs:
check-pr-checklist:
runs-on: ubuntu-latest
steps:
- name: Check if all checklist items are completed
uses: actions/github-script@v7
with:
script: |
const prNumber = context.payload.pull_request.number;
const { data: pr } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNumber,
});
const checklistRegex = /- \[([ xX])\] .*/g;
const checklistItems = pr.body?.match(checklistRegex) || [];
const allChecked = checklistItems.every(item => item.toLowerCase().includes("[x]"));
const commentBody = "⚠️ Please complete all checklist items before merging. ⚠️";
const marker = "<!-- checklist-warning -->";
const { data: comments } = await github.rest.issues.listComments({
issue_number: prNumber,
owner: context.repo.owner,
repo: context.repo.repo,
});
const existingComment = comments.find(comment => comment.user.id == 41898282 && comment.body.includes(marker));
if (allChecked) {
if (existingComment) {
await github.rest.issues.deleteComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existingComment.id,
});
}
} else {
if (!existingComment) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: `${marker}\n${commentBody}`,
});
}
throw new Error(commentBody);
}