Files
bowenliang123 a4c2b67e72 ci: auto-close issues whose title matches a blocked pattern
Fires on issue creation; currently the only blocked pattern is
'dsh-plugin.org' (case-insensitive). Matching issues are closed as
not planned with an explanatory comment. Add further conditions by
appending to the patterns array.
2026-10-06 09:13:11 +08:00

34 lines
1.1 KiB
YAML

name: Auto-close issues
on:
issues:
types: [opened]
permissions:
issues: write
jobs:
auto-close:
runs-on: ubuntu-latest
steps:
- name: Close the issue as not planned when its title matches a blocked pattern
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
ISSUE_TITLE: ${{ github.event.issue.title }}
run: |
# One case-insensitive substring per line; a title matching any of
# them gets the issue closed as not planned.
patterns=(
'dsh-plugin.org'
)
title="$(printf '%s' "$ISSUE_TITLE" | tr '[:upper:]' '[:lower:]')"
for pattern in "${patterns[@]}"; do
if [[ "$title" == *"$pattern"* ]]; then
gh issue close "$ISSUE_NUMBER" --repo "$GITHUB_REPOSITORY" --reason "not planned" \
--comment "Closed automatically: the title matches a blocked pattern (\`$pattern\`)."
exit 0
fi
done
echo "No blocked pattern matched; leaving the issue open."