This commit is contained in:
Tw93
2025-08-29 10:42:59 +08:00
5 changed files with 57 additions and 6 deletions

View File

@@ -16,9 +16,60 @@ concurrency:
cancel-in-progress: true
jobs:
auto-format:
name: Auto-fix Formatting
runs-on: ubuntu-latest
if: github.ref != 'refs/heads/main' && github.event_name != 'pull_request'
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 10.15.0
run_install: false
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
cache: "pnpm"
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: rustfmt
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Auto-fix Prettier formatting
run: npx prettier --write . --ignore-unknown
- name: Auto-fix Rust formatting
run: cargo fmt --all --manifest-path src-tauri/Cargo.toml
- name: Commit formatting fixes
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add .
if ! git diff --staged --quiet; then
git commit -m "🎨 Auto-fix formatting issues"
git push
else
echo "No formatting changes to commit"
fi
formatting:
name: Code Formatting Check
runs-on: ubuntu-latest
needs: auto-format
if: always()
steps:
- uses: actions/checkout@v4