11name : prettier
22
33on :
4- push :
5- branches :
6- - main
74 pull_request_target :
5+ types : [opened, edited, reopened, synchronize]
86
97jobs :
108 format :
@@ -17,17 +15,26 @@ jobs:
1715 with :
1816 repository : ${{ github.event.pull_request.head.repo.full_name }}
1917 ref : ${{ github.head_ref }}
18+ fetch-depth : 0
2019 - name : Set up Node.js
2120 uses : actions/setup-node@v3
2221 with :
2322 node-version : 18
2423 - name : Install Dependencies
2524 run : npm install
2625 - 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
2835 - name : Commit changes
2936 uses : stefanzweifel/git-auto-commit-action@v5
3037 with :
3138 commit_message : " style: format code and docs with prettier"
3239 commit_user_name : idoocs
33- commit_user_email : doocs-bot@outlook.com
40+ commit_user_email : doocs-bot@outlook.com
0 commit comments