diff options
| author | vojkovic <git@vojk.au> | 2026-07-30 15:44:00 +0000 |
|---|---|---|
| committer | Brock Vojkovic <brock@vojk.au> | 2026-07-31 06:28:06 +0800 |
| commit | 057a77168d3175ce2e42e5b10f46a8df073886d5 (patch) | |
| tree | 3376f57df6f328e55bcd34d28bb2bb4ec511c5cb /.github/scripts | |
| parent | 0be6f87801022f6b0640644b5c60364891145345 (diff) | |
[ci] add ai policy checkbox detection
Diffstat (limited to '.github/scripts')
| -rw-r--r-- | .github/scripts/ai_policy.cjs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/.github/scripts/ai_policy.cjs b/.github/scripts/ai_policy.cjs new file mode 100644 index 000000000..626deb1ce --- /dev/null +++ b/.github/scripts/ai_policy.cjs @@ -0,0 +1,39 @@ +// Closes issues and prs whose authors/agents don't accept the ai policy +// https://github.com/searxng/searxng/blob/master/AI_POLICY.rst + +module.exports = async ({ github, context }) => { + const item = context.payload.pull_request || context.payload.issue; + const body = item.body || ''; + const kind = context.payload.pull_request ? 'pull request' : 'issue'; + + // https://github.com/searxng/searxng/pull/6476#discussion_r3683782481 + const hasBox = /\[[Xx]\].*AI Policy/.test(body); + const hasRef = /\[AI Policy\]:\s*https:\/\/github\.com\/searxng\/searxng\/.*AI_POLICY/.test(body); + if (hasBox && hasRef) { + return; + } + + const { owner, repo } = context.repo; + await github.rest.issues.createComment({ + owner, + repo, + issue_number: item.number, + body: + 'Hello! Thank you for your contribution.\n\n' + + `Unfortunately your ${kind} was closed as the AI Policy has not been accepted.\n\n` + + `Please open a new ${kind} after confirming your contribution aligns with our AI Policy.`, + }); + await github.rest.issues.addLabels({ + owner, + repo, + issue_number: item.number, + labels: ['invalid:slop'], + }); + await github.rest.issues.update({ + owner, + repo, + issue_number: item.number, + state: 'closed', + state_reason: 'not_planned', + }); +}; |
