File tree Expand file tree Collapse file tree 3 files changed +51
-0
lines changed Expand file tree Collapse file tree 3 files changed +51
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Auto-Format with Prettier on PR for "self-healing" PRs
2
+
3
+ on :
4
+ workflow_call :
5
+
6
+ jobs :
7
+ format :
8
+ runs-on : ubuntu-latest
9
+ steps :
10
+ - name : Checkout code
11
+ uses : actions/checkout@v4
12
+
13
+ - name : Set up Node.js
14
+ uses : actions/setup-node@v4
15
+ with :
16
+ node-version-file : ' .nvmrc'
17
+
18
+ - name : Install dependencies
19
+ run : |
20
+ npm ci
21
+
22
+ - name : Check if Prettier update PR
23
+ id : check_pr
24
+ run : |
25
+ echo "PR title: ${{ github.event.pull_request.title }}"
26
+ if [[ "${{ github.event.pull_request.title }}" =~ "bump prettier from" ]]; then
27
+ echo "Prettier update detected."
28
+ echo "prettier_update=true" >> $GITHUB_ENV
29
+ else
30
+ echo "No Prettier update detected."
31
+ echo "prettier_update=false" >> $GITHUB_ENV
32
+ fi
33
+
34
+ - name : Run Prettier to format the code
35
+ if : env.prettier_update == 'true'
36
+ run : |
37
+ npx --no prettier --write .
38
+
39
+ - name : Commit changes if formatting is done
40
+ if : env.prettier_update == 'true'
41
+ run : |
42
+ git config --global user.name 'github-actions[bot]'
43
+ git config --global user.email 'github-actions[bot]@users.noreply.github.com'
44
+ git add .
45
+ git commit -m "Auto-format codebase with Prettier" || echo "No changes to commit"
46
+ git push origin HEAD:${{ github.head_ref }}
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ name: On-PR to main
4
4
on :
5
5
pull_request :
6
6
branches : ["main"]
7
+ types : [opened, synchronize, reopened]
7
8
merge_group :
8
9
branches : ["main"]
9
10
17
18
dependabot :
18
19
uses : ./.github/workflows/99-auto-merge.yml
19
20
21
+ dependabot-prettier-self-healing :
22
+ uses : ./.github/workflows/99-auto-format-dependabot-prettier-updates.yml
23
+
20
24
codeql :
21
25
uses : ./.github/workflows/99-codeql-analysis.yml
22
26
Original file line number Diff line number Diff line change
1
+ 22
You can’t perform that action at this time.
0 commit comments