ci: hide issue moderation script from logs

This commit is contained in:
t8y2
2026-06-04 12:35:00 +08:00
parent 33175c4acd
commit 32f48cc4e1
2 changed files with 34 additions and 23 deletions
+28
View File
@@ -0,0 +1,28 @@
set -euo pipefail
issue_text="$(
jq -r '
[
.issue.title // "",
.issue.body // ""
] | join("\n")
' "$GITHUB_EVENT_PATH"
)"
issue_number="$(jq -r '.issue.number' "$GITHUB_EVENT_PATH")"
prefix="$(printf '\345\210\267')"
cn_target="$(printf '\346\230\237')"
ascii_target="$(printf '\163\164\141\162')"
pattern="${prefix}[[:space:]]*(${cn_target}|${ascii_target})"
if grep -Eiq "$pattern" <<<"$issue_text"; then
matched=true
else
matched=false
fi
{
printf 'matched=%s\n' "$matched"
printf 'issue_number=%s\n' "$issue_number"
} >>"$GITHUB_OUTPUT"
+6 -23
View File
@@ -51,31 +51,14 @@ jobs:
runs-on: ubuntu-latest
if: github.event_name == 'issues'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Evaluate issue content
id: check
run: |
python3 - <<'PYEOF'
import json
import os
import re
with open(os.environ["GITHUB_EVENT_PATH"], encoding="utf-8") as f:
event = json.load(f)
issue = event["issue"]
text = "\n".join([
issue.get("title") or "",
issue.get("body") or "",
])
# Keep this intentionally narrow. It only matches "刷星" and
# case-insensitive variants of "刷star", including optional spaces.
matched = re.search(r"刷\s*(?:星|star)", text, re.IGNORECASE) is not None
with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as f:
f.write(f"matched={'true' if matched else 'false'}\n")
f.write(f"issue_number={issue['number']}\n")
PYEOF
run: bash .github/scripts/evaluate-issue-content.sh
- name: Apply issue policy
if: steps.check.outputs.matched == 'true'