name: Auto-close LLM PRs on: pull_request_target: types: [opened] permissions: contents: read pull-requests: write jobs: close-llm-pr: name: Close PR if marked as LLM-written runs-on: ubuntu-latest steps: - name: Check PR body and close if LLM-written uses: actions/github-script@v6 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | const marker = "This PR was written entirely using an LLM"; const { owner, repo } = context.repo; const prNumber = context.payload.pull_request && context.payload.pull_request.number; if (!prNumber) { console.log('No pull request number found in context; exiting.'); return; } const { data: pr } = await github.rest.pulls.get({ owner, repo, pull_number: prNumber }); const body = pr.body || ""; if (body.includes(marker)) { if (pr.state === 'closed') { console.log(`PR #${prNumber} already closed.`); return; } await github.rest.issues.addLabels({ owner, repo, issue_number: prNumber, labels: ['spam'] }); await github.rest.issues.createComment({ owner, repo, issue_number: prNumber, body: "Closing this PR because it contains the disclosure: \"This PR was written entirely using an LLM\"." }); await github.rest.pulls.update({ owner, repo, pull_number: prNumber, state: 'closed' }); console.log(`Closed PR #${prNumber} because marker was found.`); } else { console.log(`Marker not found in PR #${prNumber}; nothing to do.`); }