Skip to content

Instantly share code, notes, and snippets.

@skullface
Created November 19, 2021 03:21
Show Gist options
  • Save skullface/6ce55840db8610a907a53eaa3c9ee22d to your computer and use it in GitHub Desktop.
Save skullface/6ce55840db8610a907a53eaa3c9ee22d to your computer and use it in GitHub Desktop.
Teensy GitHub Action to autofix linting errors (from the script defined in your package.json) per https://mskelton.medium.com/auto-formatting-code-using-prettier-and-github-actions-ed458f58b7df
name: Lint and autofix
on:
pull_request:
branches: [main]
jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- uses: actions/setup-node@v2
with:
node-version: "16.x"
- run: |
npm ci
npm run lint -- --fix
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: 🤖 linting with autofix
branch: ${{ github.head_ref }}
@skullface
Copy link
Author

To use:

  • Change line 17 with whatever your lint command with autofix flag is as defined in your package.json 😎
  • Add to your repo’s .github/workflows directory
  • ✌️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment