@@ -61,21 +61,30 @@ jobs:
6161 run : |
6262 git config --global user.name "github-actions[bot]"
6363 git config --global user.email "github-actions[bot]@users.noreply.github.com"
64+
6465 FILES=$(
6566 {
6667 git ls-files -m -- 'docs/v2' | grep '\.json$'
6768 git diff --cached --name-only --diff-filter=AM -- 'docs/v2' | grep '\.json$'
6869 git ls-files --others --exclude-standard -- 'docs/v2' | grep '\.json$'
6970 } | sort -u
7071 )
71- if [ -n "$FILES" ]; then
72- git add $FILES
73- git commit -m "chore: deploy JSON files to docs/v2 [skip ci]" || exit 0
74- git pull --rebase --autostash
75- git push origin HEAD
76- else
72+
73+ if [ -z "$FILES" ]; then
7774 echo "No JSON changes in docs/v2 to commit."
75+ exit 0
7876 fi
77+
78+ git pull --rebase --autostash
79+
80+ echo "$FILES" | xargs -d '\n' git add --
81+
82+ git commit -m "chore: deploy JSON files to docs/v2 [skip ci]" || {
83+ echo "Nothing to commit."
84+ exit 0
85+ }
86+
87+ git push origin HEAD || (git pull --rebase --autostash && git push origin HEAD)
7988 env :
8089 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
8190 deploy-v3 :
@@ -127,20 +136,29 @@ jobs:
127136 run : |
128137 git config --global user.name "github-actions[bot]"
129138 git config --global user.email "github-actions[bot]@users.noreply.github.com"
139+
130140 FILES=$(
131141 {
132142 git ls-files -m -- 'docs/v3' | grep '\.json$'
133143 git diff --cached --name-only --diff-filter=AM -- 'docs/v3' | grep '\.json$'
134144 git ls-files --others --exclude-standard -- 'docs/v3' | grep '\.json$'
135145 } | sort -u
136146 )
137- if [ -n "$FILES" ]; then
138- git add $FILES
139- git commit -m "chore: deploy JSON files to docs/v3 [skip ci]" || exit 0
140- git pull --rebase --autostash
141- git push origin HEAD
142- else
147+
148+ if [ -z "$FILES" ]; then
143149 echo "No JSON changes in docs/v3 to commit."
150+ exit 0
144151 fi
152+
153+ git pull --rebase --autostash
154+
155+ echo "$FILES" | xargs -d '\n' git add --
156+
157+ git commit -m "chore: deploy JSON files to docs/v3 [skip ci]" || {
158+ echo "Nothing to commit."
159+ exit 0
160+ }
161+
162+ git push origin HEAD || (git pull --rebase --autostash && git push origin HEAD)
145163 env :
146164 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments