Skip to content

Commit

Permalink
GitHub action to automatically run eslint --fix on PRs and commit the…
Browse files Browse the repository at this point in the history
… changes (#35)
  • Loading branch information
Narinder788 authored Oct 6, 2024
1 parent 79472c1 commit 88dfb15
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions .github/workflows/pr-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}

- name: Set up Node.js
uses: actions/setup-node@v3
Expand All @@ -32,3 +34,16 @@ jobs:

- name: Build
run: npm run build

- name: Auto-fix ESLint Issues
run: npx eslint . --fix

- name: Commit changes if any
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add .
git diff --quiet || git commit -m "ESLint auto-fix applied by GitHub Actions" || exit 0
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GitHub token for authentication

0 comments on commit 88dfb15

Please sign in to comment.