-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
67 lines (55 loc) · 1.7 KB
/
pretty-fix.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
67
name: Prettier Fix
env:
PNPM_VERSION: "9.6.0"
NODE_VERSION: "20.16.0"
permissions:
contents: write
on:
pull_request_target:
types: [labeled]
jobs:
prettify:
runs-on: ubuntu-latest
if: github.event.label.name == 'prettify'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- name: Install prettier
run: pnpm add -g [email protected]
- name: Get changed files
id: get-changed-files
uses: actions/github-script@v7
with:
script: |
const changedFiles = await github.paginate(
github.rest.pulls.listFiles,
{
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
}
);
return changedFiles.filter(file=> file.status !== "removed").map(file => file.filename).join(' ');
- name: Run Prettier fix
run: |
CHANGED_FILES=$(echo ${{ steps.get-changed-files.outputs.result }})
if [ -n "$CHANGED_FILES" ]; then
pnpm prettier --write $CHANGED_FILES
fi
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "prettier fix"
- name: Remove label
uses: PauMAVA/[email protected]
with:
issue_number: ${{ github.event.pull_request.number }}
remove: "prettify"