-
Notifications
You must be signed in to change notification settings - Fork 6
56 lines (47 loc) · 1.53 KB
/
prettier.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
name: Lint
on:
pull_request:
push:
branches:
- main
jobs:
prettier:
name: Prettier
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up pnpm
uses: pnpm/[email protected]
with:
version: latest
- name: Install dependencies
run: pnpm install
- name: Check for formatting issues
id: prettier-check
run: |
pnpm exec prettier --check "**/*.{js,jsx,ts,tsx,json,css,md}"
continue-on-error: true
- name: Set formatting result
id: set-formatting-result
run: |
if grep -q "Code style issues found" <<<"${{ steps.prettier-check.outputs.stdout }}"; then
echo "formatting-required=true" >> $GITHUB_ENV
else
echo "formatting-required=false" >> $GITHUB_ENV
fi
- name: Comment on the PR if formatting is required
if: env.formatting-required == 'true'
uses: actions/github-script@v7
with:
script: |
const issue_number = context.payload.pull_request.number;
github.rest.issues.createComment({
issue_number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "Some files aren't properly formatted. Would you like me to lint them for you?"
})
- name: Run Prettier
if: env.formatting-required == 'true'
run: pnpm exec prettier --write "**/*.{js,jsx,ts,tsx,json,css,md}"