Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e221027

Browse files
thinkasanyyanglbme
andauthored
chore: only prettify changed files (doocs#1786)
--------- Co-authored-by: Libin YANG <contact@yanglibin.info>
1 parent 59035f2 commit e221027

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

‎.github/workflows/prettier.yml‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
name: prettier
22

33
on:
4-
push:
5-
branches:
6-
- main
74
pull_request_target:
5+
types: [opened, edited, reopened, synchronize]
86

97
jobs:
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

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /