mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-10-07 02:07:47 +08:00
package.json moved to Biome 2.5.7 but the auto-format job stayed on 2.4.13. The two format some files differently, so on this PR the bot reformatted tests/unit/log-save-route.test.ts with 2.4.13 and the lint job, on 2.5.7, then failed on it. The pin now matches package.json, as its comment asks, and the file is back in 2.5.7's format.
57 lines
2.0 KiB
YAML
57 lines
2.0 KiB
YAML
name: Auto Format
|
|
|
|
on:
|
|
pull_request:
|
|
types: [opened, synchronize]
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
format:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v6
|
|
with:
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v6
|
|
with:
|
|
node-version: '24'
|
|
|
|
- name: Run Biome format
|
|
# Pin to the version in package.json so CI matches local/pre-commit
|
|
# (npx @latest drifts — e.g. 2.5.0 broke this job on unrelated PRs).
|
|
run: npx @biomejs/[email protected] check --write --no-errors-on-unmatched .
|
|
|
|
- name: Check for changes
|
|
id: changes
|
|
run: |
|
|
if git diff --quiet; then
|
|
echo "has_changes=false" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "has_changes=true" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
# For fork PRs, just fail if formatting is needed (can't push to forks)
|
|
- name: Fail if fork PR needs formatting
|
|
if: steps.changes.outputs.has_changes == 'true' && github.event.pull_request.head.repo.full_name != github.repository
|
|
run: |
|
|
echo "::error::This PR has formatting issues. Please run 'npx @biomejs/biome check --write .' locally and push the changes."
|
|
git diff --stat
|
|
exit 1
|
|
|
|
# For same-repo PRs, commit and push the changes
|
|
- name: Commit changes
|
|
if: steps.changes.outputs.has_changes == 'true' && github.event.pull_request.head.repo.full_name == github.repository
|
|
run: |
|
|
git config --global user.name "github-actions[bot]"
|
|
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
|
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
|
|
git add .
|
|
git commit -m "style: auto-format with Biome"
|
|
git push origin HEAD:${{ github.head_ref }}
|