chore(workflow): update format job #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Format | |
on: | |
pull_request: | |
branches: | |
- main | |
push: | |
branches: | |
- main | |
jobs: | |
format: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18.17.0' | |
- name: Cache npm dependencies | |
id: cache-npm | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.npm | |
node_modules | |
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Install dependencies | |
run: npm install | |
- name: Verify Prettier version | |
run: npx prettier --version | |
- name: Check Prettier configuration | |
run: cat .prettierrc | |
- name: Check Prettier formatting | |
run: | | |
echo "Checking Prettier formatting..." | |
npm run prettier:check || echo "Prettier check failed" | |
- name: Run Prettier to fix formatting issues | |
if: failure() | |
run: | | |
echo "Running Prettier to fix formatting issues..." | |
npm run prettier:write | |
- name: Verify Prettier formatting on latest commit | |
if: success() | |
run: npm run prettier:check |