Skip to content

Commit 38ba5bb

Browse files
authored
Harden auto-approve: never self-approve guardrail changes (#758)
Add a check that skips auto-approval when a PR modifies .github/** or .shadow.yml. Without it, a PR that weakens the approval gate (or repoints the bot at a different engine) is approved by the very gate it edits. Paginates listFiles so a large PR cannot slip a guarded file past a 30-item page.
1 parent 18094c1 commit 38ba5bb

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

.github/workflows/auto-approve.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,21 @@ jobs:
5555
return;
5656
}
5757
58+
// Condition 0: never auto-approve a PR that changes the bot's own
59+
// guardrails (workflows or engine config) — that lets a PR weaken
60+
// the approval gate and be approved by the very gate it edits.
61+
// Require a human for these.
62+
const files = await github.paginate(github.rest.pulls.listFiles, {
63+
owner, repo, pull_number: prNumber, per_page: 100
64+
});
65+
const guarded = files.find(f =>
66+
f.filename.startsWith('.github/') || f.filename === '.shadow.yml'
67+
);
68+
if (guarded) {
69+
core.info(`PR touches guarded path ${guarded.filename} — requires human review, skipping`);
70+
return;
71+
}
72+
5873
// Condition 1: CI must have passed for this SHA
5974
const {data: workflowRuns} = await github.rest.actions.listWorkflowRunsForRepo({
6075
owner, repo, head_sha: sha, status: 'completed'

0 commit comments

Comments
 (0)