Skip to content

Commit

Permalink
[fix]: prettier ci
Browse files Browse the repository at this point in the history
  • Loading branch information
sanam2405 committed Dec 31, 2023
1 parent e9a1fcb commit f1769c5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
28 changes: 17 additions & 11 deletions .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,36 @@ on:

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

steps:

# Check out the repository
- name: Checkout code
uses: actions/checkout@v2

# Install Node.js
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 21.1.0

# Install the dependencies
- name: Install dependencies
run: npm ci --only=dev

# Check Prettier formatting
- name: Run Prettier
run: npm run prettier:github-action

- name: Check Prettier formatting
id: prettier-status
run: |
npm run format -- --check
if [ $? -ne 0 ]; then
echo "Prettier formatting check failed"
exit 1
fi
npm run prettier:github-action || echo 'failed'
echo "::set-output name=prettier-status::${{ steps.prettier-status.outputs.stdout }}"
enforce-prettier:
name: Enforce Prettier
needs: prettier
runs-on: ubuntu-latest
if: ${{ needs.prettier.outputs.prettier-status == 'failed' }}

steps:
- name: Fail the build on Prettier errors
run: exit 1
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"lint": "eslint \"./{frontend,backend}/**/*.{js,jsx}\" --quiet",
"lint-fix": "eslint --fix \"./{frontend,backend}/**/*.{js,jsx}\" --quiet",
"format": "prettier --write \"./{frontend,backend}/**/*.{html,css,js,jsx}\"",
"eslint:github-action": "eslint \"./{frontend,backend}/**/*.{js,jsx}\" --quiet"
"eslint:github-action": "eslint \"./{frontend,backend}/**/*.{js,jsx}\" --quiet",
"prettier:github-action": "prettier --check \"./{frontend,backend}/**/*.{html,css,js,jsx}\""
},
"repository": {
"type": "git",
Expand Down

0 comments on commit f1769c5

Please sign in to comment.