mirror of
https://github.com/searxng/searxng.git
synced 2026-10-19 01:47:04 +00:00
[enh] ci: convert script to esm (#6725)
Some checks failed
Sync / Codeberg (push) Has been cancelled
Documentation / Release (push) Has been cancelled
Integration / Python 3.11 (push) Has been cancelled
Integration / Python 3.12 (push) Has been cancelled
Integration / Python 3.13 (push) Has been cancelled
Integration / Python 3.14 (push) Has been cancelled
Integration / Theme (push) Has been cancelled
Some checks failed
Sync / Codeberg (push) Has been cancelled
Documentation / Release (push) Has been cancelled
Integration / Python 3.11 (push) Has been cancelled
Integration / Python 3.12 (push) Has been cancelled
Integration / Python 3.13 (push) Has been cancelled
Integration / Python 3.14 (push) Has been cancelled
Integration / Theme (push) Has been cancelled
Embraces the ESM format. Allow spaces between the checkbox `([ x ])`
This commit is contained in:
parent
d8ae3abd59
commit
12f8b6515c
4 changed files with 44 additions and 42 deletions
41
.github/scripts/aiPolicy.mjs
vendored
Normal file
41
.github/scripts/aiPolicy.mjs
vendored
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
// @ts-check
|
||||
// Closes issues and prs whose authors/agents don't accept the ai policy
|
||||
// https://github.com/searxng/searxng/blob/master/AI_POLICY.rst
|
||||
|
||||
const boxCocRegex = /\[\s*[Xx]\s*\].*AI Policy/;
|
||||
const refCocRegex = /\[AI Policy\](?::\s*|\()https:\/\/github\.com\/searxng\/searxng\/.*AI_POLICY/;
|
||||
|
||||
export default async ({ github, context }) => {
|
||||
const item = context.payload.issue ?? context.payload.pull_request;
|
||||
if (!item?.body) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (boxCocRegex.test(item.body) && refCocRegex.test(item.body)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const type = context.payload.issue ? "issue" : "pull request";
|
||||
|
||||
await github.rest.issues.createComment({
|
||||
issue_number: item.number,
|
||||
body: `Hello! Thank you for your contribution.
|
||||
|
||||
Unfortunately your ${type} was closed as the AI Policy has not been accepted.
|
||||
Please open a new ${type} after confirming your contribution aligns with our AI Policy.`,
|
||||
...context.repo
|
||||
});
|
||||
|
||||
await github.rest.issues.addLabels({
|
||||
issue_number: item.number,
|
||||
labels: ["invalid:slop"],
|
||||
...context.repo
|
||||
});
|
||||
|
||||
await github.rest.issues.update({
|
||||
issue_number: item.number,
|
||||
state: "closed",
|
||||
state_reason: "not_planned",
|
||||
...context.repo
|
||||
});
|
||||
};
|
||||
39
.github/scripts/ai_policy.cjs
vendored
39
.github/scripts/ai_policy.cjs
vendored
|
|
@ -1,39 +0,0 @@
|
|||
// 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',
|
||||
});
|
||||
};
|
||||
6
.github/workflows/ai-policy.yml
vendored
6
.github/workflows/ai-policy.yml
vendored
|
|
@ -18,7 +18,7 @@ permissions:
|
|||
|
||||
jobs:
|
||||
check:
|
||||
name: Check AI Policy
|
||||
name: Check
|
||||
# for issues with an author who has not contributed before
|
||||
if: >-
|
||||
github.event.sender.type != 'Bot' &&
|
||||
|
|
@ -34,5 +34,5 @@ jobs:
|
|||
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||||
with:
|
||||
script: |
|
||||
const script = require('./.github/scripts/ai_policy.cjs');
|
||||
await script({ github, context });
|
||||
const script = await import("${{ github.workspace }}/.github/scripts/aiPolicy.mjs")
|
||||
await script.default({ github, context });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue