Skip to content
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
18 changes: 14 additions & 4 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
ref: ${{ github.event.pull_request.head.repo.full_name == github.repository && github.head_ref || '' }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Node.js
Expand All @@ -27,10 +27,10 @@ jobs:
run: npm ci

- name: Run Prettier
run: npx prettier --write "src/**/*.{ts,tsx,js,jsx,json,css,scss,md}"
run: npm run format

- name: Run ESLint Fix
run: npx eslint --fix "src/**/*.{ts,tsx}"
run: npm run lint:fix

- name: Check for changes
id: changes
Expand All @@ -41,8 +41,9 @@ jobs:
echo "has_changes=false" >> $GITHUB_OUTPUT
fi

# Auto-commit for internal PRs
- name: Commit formatting changes
if: steps.changes.outputs.has_changes == 'true'
if: steps.changes.outputs.has_changes == 'true' && github.event.pull_request.head.repo.full_name == github.repository
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
Expand All @@ -51,3 +52,12 @@ jobs:

🤖 Automated formatting by GitHub Actions"
git push

# Fail for fork PRs so contributors know to run formatting locally
- name: Require formatted code (fork PRs)
if: steps.changes.outputs.has_changes == 'true' && github.event.pull_request.head.repo.full_name != github.repository
run: |
echo "::error::Code is not formatted. Please run these commands locally and push:"
echo " npm run format"
echo " npm run lint:fix"
exit 1
Loading
Loading