Skip to content

Commit

Permalink
Update prettier.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
armanmoztar authored Sep 10, 2024
1 parent 42bf604 commit 8d5821e
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ on:
push:
branches:
- main

jobs:
prettier:
name: Prettier
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up pnpm
uses: pnpm/[email protected]
Expand All @@ -25,10 +26,20 @@ jobs:
- name: Check for formatting issues
id: prettier-check
run: |
pnpm exec prettier --check "**/*.{js,jsx,ts,tsx,json,css,md}" || echo "formatting-required"
pnpm exec prettier --check "**/*.{js,jsx,ts,tsx,json,css,md}"
continue-on-error: true

- name: Set formatting result
id: set-formatting-result
run: |
if grep -q "Code style issues found" <<<"${{ steps.prettier-check.outputs.stdout }}"; then
echo "formatting-required=true" >> $GITHUB_ENV
else
echo "formatting-required=false" >> $GITHUB_ENV
fi
- name: Comment on the PR if formatting is required
if: steps.prettier-check.outputs.formatting-required
if: env.formatting-required == 'true'
uses: actions/github-script@v7
with:
script: |
Expand All @@ -41,4 +52,5 @@ jobs:
})
- name: Run Prettier
run: pnpm exec prettier --check "**/*.{js,jsx,ts,tsx,json,css,md}"
if: env.formatting-required == 'true'
run: pnpm exec prettier --write "**/*.{js,jsx,ts,tsx,json,css,md}"

0 comments on commit 8d5821e

Please sign in to comment.