Skip to content
41 changes: 41 additions & 0 deletions .github/workflows/prettier-eslint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Prettier Lint and Format
on:
pull_request:
branches:
- main
permissions:
contents: write
pull-requests: write
jobs:
prettier-lint-and-format:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "20.x"
- name: Install Dependencies
run: |
cd ./server && npm i
cd ../client && npm i --force
- name: Run ESLint and Prettier
working-directory: ./client
run: |
npm run lint
npm run format
- name: Check for changes
id: git-check
run: |
git diff --exit-code || echo "has_changes=true" >> $GITHUB_OUTPUT
- name: Commit changes
if: steps.git-check.outputs.has_changes == 'true'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -am "style: format code with prettier and fix lint issues"
git push
Loading