feat: 更新 Ruff 工作流,仅在对分支的push时启动Ruff检查

pull/981/head
墨梓柒 2025-05-21 22:50:17 +08:00
parent 344a8baf22
commit 7acee94ee4
No known key found for this signature in database
GPG Key ID: 4A65B9DBA35F7635
1 changed files with 13 additions and 3 deletions

View File

@ -1,5 +1,12 @@
name: Ruff
on: [ push ]
on:
push:
branches:
- main
- dev
- dev-refactor # 例如:匹配所有以 feature/ 开头的分支
# 添加你希望触发此 workflow 的其他分支
permissions:
contents: write
@ -7,6 +14,10 @@ permissions:
jobs:
ruff:
runs-on: ubuntu-latest
# 关键修改:添加条件判断
# 确保只有在 event_name 是 'push' 且不是由 Pull Request 引起的 push 时才运行
if: github.event_name == 'push' && !startsWith(github.ref, 'refs/pull/')
steps:
- uses: actions/checkout@v4
with:
@ -25,5 +36,4 @@ jobs:
git config --local user.name "github-actions[bot]"
git add -A
git diff --quiet && git diff --staged --quiet || git commit -m "🤖 自动格式化代码 [skip ci]"
git push
git push