name: Lint and Format on: push: branches: ["**"] pull_request: branches: ["**"] jobs: lint: name: ESLint runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Setup Node uses: actions/setup-node@v4 with: node-version: "24" cache: "npm" - name: Enable corepack and install npm run: | corepack enable corepack prepare npm@latest --activate - name: Install dependencies run: npm install --frozen-lockfile - name: Run ESLint run: npm lint - name: Run Prettier check run: npm format:check format: name: Auto-format (eslint --fix) runs-on: ubuntu-latest needs: lint if: github.event_name == 'push' steps: - name: Checkout uses: actions/checkout@v4 with: persist-credentials: true - name: Setup Node uses: actions/setup-node@v4 with: node-version: "24" cache: "npm" - name: Enable corepack and install npm run: | corepack enable corepack prepare npm@latest --activate - name: Install dependencies run: npm install --frozen-lockfile - name: Run Prettier --write run: npm format - name: Run ESLint --fix run: npm lint:fix - name: Commit & push fixes run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" if ! git diff --quiet; then git add -A git commit -m "chore: auto format by GitHub Actions" || echo "No changes to commit" git push else echo "No formatting changes" fi env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}