1
1
name : prettier
2
2
3
3
on :
4
- push :
5
- branches :
6
- - main
7
4
pull_request_target :
5
+ types : [opened, edited, reopened, synchronize]
8
6
9
7
jobs :
10
8
format :
@@ -17,17 +15,26 @@ jobs:
17
15
with :
18
16
repository : ${{ github.event.pull_request.head.repo.full_name }}
19
17
ref : ${{ github.head_ref }}
18
+ fetch-depth : 0
20
19
- name : Set up Node.js
21
20
uses : actions/setup-node@v3
22
21
with :
23
22
node-version : 18
24
23
- name : Install Dependencies
25
24
run : npm install
26
25
- name : Run prettier
27
- run : npx prettier --write "**/*.{md,js,ts,php,sql}"
26
+ run : |
27
+ git config --global core.quotepath off
28
+ changed_files=$(git diff --name-only "${{ github.event.pull_request.base.sha }}" | grep -E '\.md$|\.js$|\.ts$|\.php|\.sql$' || true)
29
+ if [ -n "$changed_files" ]; then
30
+ echo "Running prettier on the changed files"
31
+ echo "$changed_files" | xargs -d '\n' npx prettier --write
32
+ else
33
+ echo "No matching files to run prettier on."
34
+ fi
28
35
- name : Commit changes
29
36
uses : stefanzweifel/git-auto-commit-action@v5
30
37
with :
31
38
commit_message : " style: format code and docs with prettier"
32
39
commit_user_name : idoocs
33
- commit_user_email : doocs-bot@outlook.com
40
+ commit_user_email : doocs-bot@outlook.com
0 commit comments