-
Notifications
You must be signed in to change notification settings - Fork 8
39 lines (38 loc) · 1.32 KB
/
format_and_lint.yml
File metadata and controls
39 lines (38 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# This workflow will do a clean install of node dependencies, format the code with Prettier, lint with ESLint and commit any resulting changes
# For more information see:
# - https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
# - https://github.com/stefanzweifel/git-auto-commit-action
name: Format and Lint
on:
push:
pull_request_target:
branches: [ main ]
jobs:
clean:
runs-on: ubuntu-latest
steps:
- name: Check out branch (pull request)
uses: actions/checkout@v2
if: github.event_name == 'pull_request_target' || github.event_name == 'pull_request'
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- name: Check out branch (push)
uses: actions/checkout@v2
if: github.event_name == 'push'
with:
ref: ${{ github.head_ref }}
- name: Use Node.js 16.x
uses: actions/setup-node@v2
with:
node-version: "16.x"
- name: Install packages
run: npm ci
- name: Format with Prettier
run: npx prettier --write .
- name: Lint with ESLint
run: npx eslint --fix .
- name: Commit Changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Apply Prettier/ESLint fixes with CI