@@ -147,31 +147,91 @@ jobs:
147147
148148 run_openai_refresh
149149
150- - name : Commit and push locale artifact
150+ - name : Prepare locale artifact
151151 env :
152152 LOCALE : ${{ matrix.locale }}
153+ run : |
154+ set -euo pipefail
155+ artifact_dir="${RUNNER_TEMP}/native-locale-${LOCALE}"
156+ mkdir -p "${artifact_dir}"
157+ git add -A apps/.i18n/native
158+ git diff --cached --binary --full-index -- apps/.i18n/native > "${artifact_dir}/${LOCALE}.patch"
159+
160+ - name : Upload locale artifact
161+ uses : actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
162+ with :
163+ name : native-locale-${{ matrix.locale }}
164+ path : ${{ runner.temp }}/native-locale-${{ matrix.locale }}/${{ matrix.locale }}.patch
165+ if-no-files-found : error
166+ retention-days : 1
167+
168+ finalize :
169+ name : Commit native locale refresh
170+ needs : refresh
171+ if : needs.refresh.result == 'success'
172+ runs-on : ubuntu-latest
173+ steps :
174+ - name : Checkout
175+ uses : actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
176+ with :
177+ fetch-depth : 0
178+ persist-credentials : true
179+ submodules : false
180+
181+ - name : Download locale artifacts
182+ uses : actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
183+ with :
184+ pattern : native-locale-*
185+ path : ${{ runner.temp }}/native-locale-artifacts
186+ merge-multiple : true
187+
188+ - name : Apply locale artifacts
189+ run : |
190+ set -euo pipefail
191+ while IFS= read -r patch; do
192+ if [ -s "${patch}" ]; then
193+ git apply "${patch}"
194+ fi
195+ done < <(find "${RUNNER_TEMP}/native-locale-artifacts" -type f -name '*.patch' | sort)
196+
197+ - name : Setup Node environment
198+ uses : ./.github/actions/setup-node-env
199+ with :
200+ install-bun : " false"
201+
202+ # Every worker observes the same source inventory. Generate it once here
203+ # so locale patches remain independent and can be applied sequentially.
204+ - name : Refresh shared native inventory
205+ run : node --import tsx scripts/native-app-i18n.ts sync --write
206+
207+ - name : Validate native locale refresh
208+ run : node --import tsx scripts/native-app-i18n.ts check
209+
210+ - name : Commit and push aggregate locale refresh
211+ env :
153212 TARGET_BRANCH : ${{ github.event.repository.default_branch }}
154213 run : |
155214 set -euo pipefail
156215 if ! git status --porcelain -- apps/.i18n/native apps/.i18n/native-source.json | grep -q .; then
157- echo "No native locale changes for ${LOCALE} ."
216+ echo "No native locale changes."
158217 exit 0
159218 fi
160219
161220 git config user.name "github-actions[bot]"
162221 git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
163222 git add -A apps/.i18n/native apps/.i18n/native-source.json
164- git commit --no-verify -m "chore(i18n): refresh native ${LOCALE} locale "
223+ git commit --no-verify -m "chore(i18n): refresh native locales "
165224
166225 for attempt in 1 2 3 4 5; do
167226 git fetch origin "${TARGET_BRANCH}"
168- git rebase --autostash "origin/${TARGET_BRANCH}"
227+ git rebase "origin/${TARGET_BRANCH}"
169228 if git push origin HEAD:"${TARGET_BRANCH}"; then
170229 exit 0
171230 fi
172- echo "Push attempt ${attempt} for ${LOCALE} failed; retrying."
231+ git rebase --abort >/dev/null 2>&1 || true
232+ echo "Aggregate push attempt ${attempt} failed; retrying."
173233 sleep $((attempt * 2))
174234 done
175235
176- echo "Failed to push ${LOCALE} native locale update after retries."
236+ echo "Failed to push aggregate native locale update after retries."
177237 exit 1
0 commit comments