mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-10-15 05:40:47 +08:00
linked-issue-check only exempted drafts and the no-issue-needed label, so member and collaborator PRs failed the linkage gate while the slop review itself skipped them via skip-roles (#7944). Skip OWNER, MEMBER, COLLABORATOR, and bot authors as well, reading the association from the event payload so the permission-free gate design holds. External contributors still need an issue reference.
52 lines
2.2 KiB
YAML
52 lines
2.2 KiB
YAML
name: ai-slop-gate
|
|
|
|
# pull_request_target runs this file from the base branch, so a PR cannot
|
|
# weaken its own gates. No checkout and no secrets: every check reads only
|
|
# the event payload.
|
|
on:
|
|
pull_request_target:
|
|
types: [opened, reopened, synchronize, labeled, unlabeled, edited, ready_for_review]
|
|
|
|
permissions: {}
|
|
|
|
jobs:
|
|
gate:
|
|
name: ai-slop-gate
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Fail while ai-slop:high is present
|
|
if: contains(join(github.event.pull_request.labels.*.name, ','), 'ai-slop:high')
|
|
run: |
|
|
echo "::error::ai-slop:high is present. Resolve the ownership concerns from the AI-slop review (issue linkage, scope, or implementation changes) so the label can be removed."
|
|
exit 1
|
|
|
|
linked-issue:
|
|
name: linked-issue-check
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Require an issue reference in title or body
|
|
env:
|
|
PR_TITLE: ${{ github.event.pull_request.title }}
|
|
PR_BODY: ${{ github.event.pull_request.body }}
|
|
LABELS: ${{ join(github.event.pull_request.labels.*.name, ',') }}
|
|
DRAFT: ${{ github.event.pull_request.draft }}
|
|
ASSOCIATION: ${{ github.event.pull_request.author_association }}
|
|
AUTHOR_TYPE: ${{ github.event.pull_request.user.type }}
|
|
run: |
|
|
if [ "$DRAFT" = "true" ] || printf '%s' "$LABELS" | grep -q 'no-issue-needed'; then
|
|
echo "Draft or no-issue-needed; linkage check skipped."
|
|
exit 0
|
|
fi
|
|
# OWNER/MEMBER/COLLABORATOR and bots mirror the slop review's
|
|
# skip-roles/skip-bots trust tier.
|
|
if [ "$AUTHOR_TYPE" = "Bot" ] || [ "$ASSOCIATION" = "OWNER" ] || [ "$ASSOCIATION" = "MEMBER" ] || [ "$ASSOCIATION" = "COLLABORATOR" ]; then
|
|
echo "Bot or trusted author ($ASSOCIATION); linkage check skipped."
|
|
exit 0
|
|
fi
|
|
if printf '%s\n%s\n' "$PR_TITLE" "$PR_BODY" | grep -Eq '#[0-9]+|issues/[0-9]+'; then
|
|
echo "Issue reference found."
|
|
else
|
|
echo "::error::No issue reference found in the PR title or body. Link the issue (e.g. \"Fixes #123\"), or ask a maintainer to add the no-issue-needed label if the change is trivial."
|
|
exit 1
|
|
fi
|