From 9443eb982f86240cbaeaf5395488baa38ddf0386 Mon Sep 17 00:00:00 2001 From: Zakk Date: Wed, 18 Nov 2026 23:10:55 +1100 Subject: [PATCH] ci: close submissions that check an admission box CONTRIBUTING.md says a checklist with "checked without reading" or "AI agent without human review" checked is closed, but nothing did it: #2138 stayed open with both boxes checked until a maintainer noticed. Close such pull requests and issues when they are opened, edited or reopened. The workflow reads only the body, so pull_request_target runs no code from the pull request. --- .github/workflows/checklist_admission.yml | 40 +++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/checklist_admission.yml diff --git a/.github/workflows/checklist_admission.yml b/.github/workflows/checklist_admission.yml new file mode 100644 index 00000000..06de6a8f --- /dev/null +++ b/.github/workflows/checklist_admission.yml @@ -0,0 +1,40 @@ +name: Checklist Admission + +# CONTRIBUTING.md: each checklist carries two statements that are false for an +# honest submitter, and checking either one is the admission. Close those +# submissions here instead of waiting for a maintainer to notice. Only the +# body is read; no code from the pull request is checked out or run, which is +# what makes pull_request_target safe here. +on: + pull_request_target: + types: [opened, edited, reopened] + issues: + types: [opened, edited, reopened] + +permissions: + issues: write + pull-requests: write + +jobs: + close: + if: github.event.pull_request.state == 'open' || github.event.issue.state == 'open' + runs-on: ubuntu-latest + steps: + - name: Close a submission that checks an admission box + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + BODY: ${{ github.event.pull_request.body || github.event.issue.body }} + NUMBER: ${{ github.event.pull_request.number || github.event.issue.number }} + KIND: ${{ github.event.pull_request && 'pr' || 'issue' }} + run: | + admission='^[[:space:]]*- \[[xX]\] (I checked the boxes above without reading them\.|I am an AI agent, and this content was submitted without human review\.|我未读上面各项就勾选了。|我是 AI 代理,提交的内容未经人工审核。)' + printf '%s\n' "$BODY" | tr -d '\r' | grep -Eq "$admission" || exit 0 + comment=$(printf '%s\n\n%s' \ + "Closed under CONTRIBUTING.md: the checklist marks a statement that is false for an honest submitter (checked without reading, or submitted by an AI agent without human review). A new submission with the checklist answered truthfully is welcome." \ + "已按 CONTRIBUTING.md 关闭:确认清单勾选了诚实提交者不会勾选的项(未读即勾选,或 AI 代理未经人工审核提交)。如实填写清单后欢迎重新提交。") + if [ "$KIND" = pr ]; then + gh pr close "$NUMBER" --comment "$comment" + else + gh issue close "$NUMBER" --reason "not planned" --comment "$comment" + fi