summaryrefslogtreecommitdiff
path: root/.github/workflows/ai-policy-checkbox.yml
diff options
context:
space:
mode:
Diffstat (limited to '.github/workflows/ai-policy-checkbox.yml')
-rw-r--r--.github/workflows/ai-policy-checkbox.yml90
1 files changed, 90 insertions, 0 deletions
diff --git a/.github/workflows/ai-policy-checkbox.yml b/.github/workflows/ai-policy-checkbox.yml
new file mode 100644
index 000000000..6a8be127b
--- /dev/null
+++ b/.github/workflows/ai-policy-checkbox.yml
@@ -0,0 +1,90 @@
+---
+name: AI Policy
+
+# yamllint disable-line rule:truthy
+on:
+ issues:
+ types: [opened]
+ pull_request_target:
+ types: [opened]
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.event.issue.number || github.event.pull_request.number }}
+ cancel-in-progress: true
+
+permissions:
+ contents: read
+
+jobs:
+ issue:
+ name: Check issue
+ if: >-
+ github.event_name == 'issues' &&
+ github.event.sender.type != 'Bot' &&
+ contains(fromJSON('["NONE","FIRST_TIMER","FIRST_TIME_CONTRIBUTOR"]'),
+ github.event.issue.author_association)
+ runs-on: ubuntu-26.04
+ permissions:
+ issues: write
+ steps:
+ - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
+ with:
+ script: |
+ const body = context.payload.issue.body || '';
+ const lines = body.split(/\r?\n/).map((l) => l.trim().replace('[X]', '[x]'));
+ const ref = '[AI Policy]: https://github.com/searxng/searxng/blob/master/AI_POLICY.rst';
+ const box = '- [x] I read the [AI Policy] and hereby confirm that this issue'
+ + ' conforms with the policy.';
+ if (lines.includes(ref) && lines.includes(box)) return;
+
+ const n = context.payload.issue.number;
+ const msg = 'This issue was closed because the AI Policy box has not been ticked.\n\n'
+ + 'Please open a new issue with the checkbox ticked.';
+ await github.rest.issues.createComment({
+ owner: context.repo.owner, repo: context.repo.repo, issue_number: n,
+ body: msg,
+ });
+ await github.rest.issues.addLabels({
+ owner: context.repo.owner, repo: context.repo.repo, issue_number: n,
+ labels: ['invalid:slop'],
+ });
+ await github.rest.issues.update({
+ owner: context.repo.owner, repo: context.repo.repo, issue_number: n,
+ state: 'closed', state_reason: 'not_planned',
+ });
+
+ pull_request:
+ name: Check pull request
+ if: >-
+ github.event_name == 'pull_request_target' &&
+ github.event.sender.type != 'Bot' &&
+ contains(fromJSON('["NONE","FIRST_TIMER","FIRST_TIME_CONTRIBUTOR"]'),
+ github.event.pull_request.author_association)
+ runs-on: ubuntu-26.04
+ permissions:
+ pull-requests: write
+ steps:
+ - uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
+ with:
+ script: |
+ const body = context.payload.pull_request.body || '';
+ const lines = body.split(/\r?\n/).map((l) => l.trim().replace('[X]', '[x]'));
+ const ref = '[AI Policy]: https://github.com/searxng/searxng/blob/master/AI_POLICY.rst';
+ const box = '- [x] **I hereby confirm that this PR conforms with the [AI Policy].**';
+ if (lines.includes(ref) && lines.includes(box)) return;
+
+ const n = context.payload.pull_request.number;
+ const msg = 'This pull request was closed because the AI Policy box has not been'
+ + ' ticked.\n\nPlease open a new pull request with the checkbox ticked.';
+ await github.rest.issues.createComment({
+ owner: context.repo.owner, repo: context.repo.repo, issue_number: n,
+ body: msg,
+ });
+ await github.rest.issues.addLabels({
+ owner: context.repo.owner, repo: context.repo.repo, issue_number: n,
+ labels: ['invalid:slop'],
+ });
+ await github.rest.issues.update({
+ owner: context.repo.owner, repo: context.repo.repo, issue_number: n,
+ state: 'closed', state_reason: 'not_planned',
+ });