From 445a7c81713d4934be6206bbc48cd4c2f0ba78a6 Mon Sep 17 00:00:00 2001 From: Hunter B Date: Wed, 3 Jun 2026 20:29:50 -0700 Subject: [PATCH] ci: avoid duplicate PR gate comments --- .github/workflows/pr-gate.yml | 29 ++++++++++++++++++++--------- CHANGELOG.md | 3 +++ 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pr-gate.yml b/.github/workflows/pr-gate.yml index 40afe8c1..a953b3f6 100644 --- a/.github/workflows/pr-gate.yml +++ b/.github/workflows/pr-gate.yml @@ -73,21 +73,32 @@ jobs: } const gateMessage = enforceGate - ? 'This repository currently limits automated PR intake to contributors listed in `.github/APPROVED_CONTRIBUTORS`. This is a maintainer-safety control for code review and CI load, not a judgment on the contribution. A maintainer can reopen or grant access with `/lgtm` after review.' + ? 'This repository currently limits automated PR intake to contributors listed in `.github/APPROVED_CONTRIBUTORS`. This is a maintainer-safety control for code review and CI load, not a judgment on the contribution. A maintainer can grant recurring PR access with `/lgtm` after review; once the generated allowlist PR is merged, this pull request can be reopened or resubmitted.' : 'This repository is observing a maintainer-managed PR intake gate in dry-run mode, so this pull request is staying open. This note helps maintainers prepare the allowlist before any enforcement is considered.'; - await github.rest.issues.createComment({ + const marker = ''; + const { data: comments } = await github.rest.issues.listComments({ owner, repo, issue_number: pr.number, - body: [ - `Thanks @${pr.user.login} for taking the time to contribute.`, - '', - gateMessage, - '', - 'Please read `CONTRIBUTING.md` for the expected contribution shape. A maintainer can grant recurring PR access by commenting `/lgtm` on a pull request.', - ].join('\n'), + per_page: 100, }); + const alreadyNoted = comments.some(comment => (comment.body || '').includes(marker)); + if (!alreadyNoted) { + await github.rest.issues.createComment({ + owner, + repo, + issue_number: pr.number, + body: [ + marker, + `Thanks @${pr.user.login} for taking the time to contribute.`, + '', + gateMessage, + '', + 'Please read `CONTRIBUTING.md` for the expected contribution shape. A maintainer can grant recurring PR access by commenting `/lgtm` on a pull request.', + ].join('\n'), + }); + } if (!enforceGate) return; diff --git a/CHANGELOG.md b/CHANGELOG.md index 08c058c1..8d76b627 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 triage note and are never auto-closed by the contribution gate, while the PR gate copy makes clear that dry-run observations are about maintainer safety, not contributor quality. +- Added a PR gate marker guard so reopened unapproved PRs do not get duplicate + intake comments, and clarified that PR reopening should happen after + allowlist approval is merged. - Documented the agent and sub-agent stewardship ethos so future automation preserves human issue intake, careful PR review, and contributor credit.