fix: 修改Ruff工作流以使用自托管运行环境并优化提交条件

This commit is contained in:
墨梓柒
2025-07-13 18:01:58 +08:00
parent e987b6331f
commit c39e4b7113

View File

@@ -13,7 +13,7 @@ permissions:
jobs: jobs:
ruff: ruff:
runs-on: ubuntu-latest runs-on: self-hosted
# 关键修改:添加条件判断 # 关键修改:添加条件判断
# 确保只有在 event_name 是 'push' 且不是由 Pull Request 引起的 push 时才运行 # 确保只有在 event_name 是 'push' 且不是由 Pull Request 引起的 push 时才运行
if: github.event_name == 'push' && !startsWith(github.ref, 'refs/pull/') if: github.event_name == 'push' && !startsWith(github.ref, 'refs/pull/')
@@ -29,14 +29,20 @@ jobs:
args: "--version" args: "--version"
version: "latest" version: "latest"
- name: Run Ruff Fix - name: Run Ruff Fix
run: ruff check --fix --unsafe-fixes || true run: ruff check --fix --unsafe-fixes; if ($LASTEXITCODE -ne 0) { Write-Host "Ruff check completed with warnings" }
shell: pwsh
- name: Run Ruff Format - name: Run Ruff Format
run: ruff format || true run: ruff format; if ($LASTEXITCODE -ne 0) { Write-Host "Ruff format completed with warnings" }
shell: pwsh
- name: 提交更改 - name: 提交更改
if: success() if: success()
run: | run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com" git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]" git config --local user.name "github-actions[bot]"
git add -A git add -A
git diff --quiet && git diff --staged --quiet || git commit -m "🤖 自动格式化代码 [skip ci]" $changes = git diff --quiet; $staged = git diff --staged --quiet
git push if (-not ($changes -and $staged)) {
git commit -m "🤖 自动格式化代码 [skip ci]"
git push
}
shell: pwsh