mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-19 18:47:41 +08:00
44 lines
1.3 KiB
YAML
44 lines
1.3 KiB
YAML
# This workflow checks whether the PR author checked the "I did NOT read" item
|
|
# in the PR checklist. If so, it posts a reminder comment and closes the PR.
|
|
name: PR Checklist Check
|
|
|
|
on:
|
|
pull_request:
|
|
types: [opened, edited, reopened, synchronize]
|
|
|
|
jobs:
|
|
check-checklist:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
pull-requests: write
|
|
|
|
steps:
|
|
- name: Check if user checked "我没有认真阅读"
|
|
id: check
|
|
uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
const body = context.payload.pull_request.body || '';
|
|
|
|
// 只匹配:整行是 - [x] + 包含“没有认真阅读”
|
|
const regex = /-\s*\[\s*x\s*\].*我\*\*没有\*\*认真阅读以上内容/im;
|
|
const isBad = regex.test(body);
|
|
|
|
return isBad;
|
|
result-encoding: string
|
|
|
|
- name: Comment and close PR if checklist violated
|
|
if: steps.check.outputs.result == 'true'
|
|
uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
const prNumber = context.payload.pull_request.number;
|
|
const author = context.payload.pull_request.user.login;
|
|
|
|
await github.rest.issues.createComment({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: prNumber,
|
|
body: `👋 @${author}
|
|
|