Skip to content

GitHub action to automatically run eslint --fix on PRs and commit the changes #100

GitHub action to automatically run eslint --fix on PRs and commit the changes

GitHub action to automatically run eslint --fix on PRs and commit the changes #100

Workflow file for this run

name: Pull Request Checks
on:
pull_request:
branches:
- main
jobs:
tests-and-file-checks:

Check failure on line 9 in .github/workflows/pr-checks.yaml

View workflow run for this annotation

GitHub Actions / .github/workflows/pr-checks.yaml

Invalid workflow file

You have an error in your yaml syntax on line 9
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install dependencies
run: npm install
- name: Linting
run: npm run lint
- name: Project structure
run: npm run lint:structure
- name: Unit tests
run: npm run test:unit
- 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