-
Notifications
You must be signed in to change notification settings - Fork 5
66 lines (56 loc) · 1.83 KB
/
lint.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: Lint Check
on:
pull_request_review:
types: [submitted]
jobs:
eslint:
name: ESLint Check
runs-on: ubuntu-latest
if: github.event.review.state == 'approved'
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: '14'
- name: Install Dependencies
run: cp client/package.json ./ && yarn install
- name: Run ESLint
uses: reviewdog/action-eslint@v1
with:
reporter: github-check
github_token: ${{ secrets.GITHUB_TOKEN }}
prettier:
name: Prettier Check
runs-on: ubuntu-latest
if: github.event.review.state == 'approved'
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: '14'
- name: Install Dependencies
run: cp client/package.json ./ && yarn install
- name: Run Prettier
id: prettier_run
run: |
echo "::set-output name=prettier_output::$(npx prettier --list-different .)"
echo "$(npx prettier --list-different . > prettier.txt)"
- name: Comment on PR
if: contains(${{ steps.prettier_run.outputs.prettier_output }}, '.');
uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const fs = require('fs')
const cmdoutput = fs.readFileSync(`${process.env.GITHUB_WORKSPACE}/prettier.txt`)
console.log(cmdoutput)
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `Prettier Response:\n ${cmdoutput}`
})