hypnagaga/.github/workflows/lint.yaml
2024-08-21 17:25:43 +01:00

61 lines
1.4 KiB
YAML

name: Lint
on:
pull_request:
branches:
- main
concurrency: ${{ github.workflow }}-${{ github.ref }}
permissions:
checks: write
contents: write
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- id: checkout
name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- id: setup-node
name: Setup Node.JS
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- id: install-deps
name: Install dependencies
run: npm ci
- id: lint
name: Lint code
run: npm run lint
- id: format
name: Format code
run: npm run format
- id: get_branch_name
name: Get branch name
run: echo "branch_name=$(echo ${GITHUB_HEAD_REF})" >> $GITHUB_ENV
- id: checkout_branch
name: Checkout to branch
run: git checkout ${{ env.branch_name }}
- id: commit_and_push
name: Commit and push formatted code
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add .
git commit --allow-empty -m "lint and format"
git push origin HEAD:${{ env.branch_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}