mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-18 18:20:39 +08:00
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
78 lines
2.9 KiB
YAML
78 lines
2.9 KiB
YAML
name: Auto Close not reading issues or Fold checkboxes
|
|
|
|
on:
|
|
issues:
|
|
types: [opened]
|
|
|
|
jobs:
|
|
check-then-close-or-fold:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
issues: write
|
|
|
|
steps:
|
|
- name: Check checkbox status
|
|
id: unread-checkbox-check
|
|
uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
const texts = [
|
|
'我已在未仔细阅读这些内容的情况下勾选所有选项,并相信这不会影响问题的处理',
|
|
'I have checked all the options without carefully reading the content and believe this will not affect issue resolution.'];
|
|
return texts.some(text => new RegExp(`- \\[x\\]\\s*${text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`).test(context.payload.issue.body));
|
|
|
|
- name: Close and lock issue
|
|
if: steps.unread-checkbox-check.outputs.result == 'true'
|
|
uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
await github.rest.issues.update({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: context.issue.number,
|
|
state: 'closed',
|
|
state_reason: 'not_planned'
|
|
});
|
|
|
|
await github.rest.issues.lock({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: context.issue.number,
|
|
lock_reason: 'spam'
|
|
});
|
|
|
|
- name: Fold checkboxes
|
|
if: steps.unread-checkbox-check.outputs.result == 'false'
|
|
uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
const originalBody = context.payload.issue.body;
|
|
const checkboxSectionRegex_cn_bug = /([\s\S]*?)(### 问题描述\n\n)/;
|
|
const checkboxSectionRegex_cn_feat = /([\s\S]*?)(### 说说你遇到的问题?\n\n)/;
|
|
const checkboxSectionRegex_en_bug = /([\s\S]*?)(### Description\n\n)/;
|
|
const checkboxSectionRegex_en_feat = /([\s\S]*?)(### The problems you have encountered?\n\n)/;
|
|
|
|
const foldedBody_cn_bug = originalBody.replace(
|
|
checkboxSectionRegex_cn_bug,
|
|
`<details><summary>Checkboxes</summary>\n\n$1\n\n</details>\n\n$2`
|
|
);
|
|
const foldedBody_cn_feat = foldedBody_cn_bug.replace(
|
|
checkboxSectionRegex_cn_feat,
|
|
`<details><summary>Checkboxes</summary>\n\n$1\n\n</details>\n\n$2`
|
|
);
|
|
const foldedBody_en_bug = foldedBody_cn_feat.replace(
|
|
checkboxSectionRegex_en_bug,
|
|
`<details><summary>Checkboxes</summary>\n\n$1\n\n</details>\n\n$2`
|
|
);
|
|
const foldedBody = foldedBody_en_bug.replace(
|
|
checkboxSectionRegex_en_feat,
|
|
`<details><summary>Checkboxes</summary>\n\n$1\n\n</details>\n\n$2`
|
|
);
|
|
|
|
await github.rest.issues.update({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: context.issue.number,
|
|
body: foldedBody
|
|
});
|