-
Notifications
You must be signed in to change notification settings - Fork 368
44 lines (43 loc) · 1.31 KB
/
prettier-eslint.yml
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
40
41
42
43
44
name: Prettier Lint and Format
on:
push:
branches:
- main
permissions:
contents: write
jobs:
prettier-lint-and-format:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "20.x"
- name: Install Dependencies
run: |
cd ./server && npm i
cd ../client && npm i --force
- name: Run ESLint and Prettier
working-directory: ./client
run: |
npm run lint
npm run format
- name: Check for changes
id: git-check
run: |
git diff --quiet || echo "has_changes=true" >> $GITHUB_OUTPUT
- name: Commit changes
if: steps.git-check.outputs.has_changes == 'true'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -am "style: format code with prettier and fix lint issues"
git add -A
git push