Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: merge fix.yml into check-and-fix.yml #26

Merged
merged 1 commit into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 57 additions & 7 deletions .github/workflows/fix.yml → .github/workflows/check-and-fix.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
name: fix
name: check and fix

on:
workflow_run:
workflows: ["check"]
types:
- completed
push:
branches:
- "main"
pull_request:
types: [opened, synchronize, reopened]
paths:
- "**.json"
- "scripts/check.py"
- "scripts/fix_*.py"
- "scripts/create_rules_markdown.py"
- ".github/workflows/fix.yml"
- ".github/workflows/check-and-fix.yml"

defaults:
run:
Expand All @@ -20,8 +21,57 @@ permissions:
contents: write

jobs:
check-forbid:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: astral-sh/setup-uv@v5
with:
version: "0.5.9"
enable-cache: true

- name: Check for forbidden file changes
run: |
forbidden_files=(
"rules.md"
"diff.md"
"bilibili-danmu-blocklist-output.json"
)
changed_files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }})
for file in "${forbidden_files[@]}"; do
if echo "$changed_files" | grep -q "$file"; then
echo "Error: Forbidden file $file was modified in this PR."
exit 1
fi
done

check-json:
needs: check-forbid
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: astral-sh/setup-uv@v5
with:
version: "0.5.9"
enable-cache: true

- name: Set up Python
run: uv python install 3.13

- name: Install the project
run: uv sync --all-extras --dev

- name: Check the json file
run: uv run scripts/check.py

fix:
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request' || github.event_name == 'pull_request' }}
needs: check-json
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
64 changes: 0 additions & 64 deletions .github/workflows/check.yml

This file was deleted.

Loading