Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(github-actions): add Prettier auto-correct for lint issues on PRs #714

Merged
merged 9 commits into from
Oct 22, 2024
44 changes: 44 additions & 0 deletions .github/workflows/prettier-eslint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Prettier Lint and Format
on:
push:
branches:
- main

permissions:
contents: write
jobs:
prettier-lint-and-format:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
Dun-sin marked this conversation as resolved.
Show resolved Hide resolved
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
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 --quiet || 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 add -A
git push
Loading