@@ -190,6 +190,7 @@ jobs:
190190 SOURCE_PR : ${{ steps.pr.outputs.pr_number }}
191191 SOURCE_PR_URL : ${{ steps.pr.outputs.html_url }}
192192 REMOVED_FILES : ${{ steps.collect.outputs.removed_cn }}
193+ TRANSLATION_BRANCH : ${{ steps.branch.outputs.branch }}
193194 with :
194195 script : |
195196 const branch = '${{ steps.branch.outputs.branch }}';
@@ -254,30 +255,8 @@ jobs:
254255 title: updatedTitle,
255256 body: updatedBody,
256257 });
257- - name : Remove translation init marker
258+ - name : Finalize translation branch
258259 if : steps.branch.outputs.branch != ''
259- env :
260- TRANSLATION_BRANCH : ${{ steps.branch.outputs.branch }}
261- run : |
262- set -euo pipefail
263- git fetch origin "$TRANSLATION_BRANCH"
264- git checkout "$TRANSLATION_BRANCH"
265-
266- if [ -f ".translation-init" ]; then
267- git rm -f .translation-init
268-
269- if git status --porcelain | grep .; then
270- git config user.name "github-actions[bot]"
271- git config user.email "github-actions[bot]@users.noreply.github.com"
272- git commit -m "chore: remove translation init marker"
273- git push origin "$TRANSLATION_BRANCH"
274- fi
275- fi
276- - name : Apply deletions to translation branch
277- if : >
278- steps.collect.outputs.has_inputs == 'true' &&
279- steps.collect.outputs.has_removals == 'true' &&
280- steps.branch.outputs.branch != ''
281260 env :
282261 REMOVED_FILES : ${{ steps.collect.outputs.removed_cn }}
283262 TRANSLATION_BRANCH : ${{ steps.branch.outputs.branch }}
@@ -290,23 +269,35 @@ jobs:
290269 sudo chown -R "$(id -u)":"$(id -g)" .git docs || true
291270 fi
292271
293- for file in $REMOVED_FILES; do
294- if [ -f "$file" ]; then
295- rm -f "$file"
296- echo "Removed $file"
297- fi
298- done
272+ changed=0
299273
300- find docs/cn -mindepth 1 -type d -empty -print -delete
274+ if [ -f ".translation-init" ]; then
275+ git rm -f .translation-init
276+ echo "Removed .translation-init"
277+ changed=1
278+ fi
279+
280+ if [ -n "$REMOVED_FILES" ]; then
281+ for file in $REMOVED_FILES; do
282+ if [ -f "$file" ]; then
283+ rm -f "$file"
284+ echo "Removed $file"
285+ changed=1
286+ fi
287+ done
288+ if [ -d docs/cn ]; then
289+ find docs/cn -mindepth 1 -type d -empty -print -delete
290+ fi
291+ fi
301292
302- if git status --porcelain | grep . ; then
293+ if [ "$changed" -eq 1 ] ; then
303294 git config user.name "github-actions[bot]"
304295 git config user.email "github-actions[bot]@users.noreply.github.com"
305296 git add -A
306- git commit -m "chore: sync deletions for PR #${{ steps.pr.outputs.pr_number }}"
297+ git commit -m "chore: finalize translation for PR #${{ steps.pr.outputs.pr_number }}"
307298 git push origin "$TRANSLATION_BRANCH"
308299 else
309- echo "No deletions to commit."
300+ echo "No cleanup changes to commit."
310301 fi
311302
312303 - name : Prepare deletion-only changes
0 commit comments