History

fix(mobile): preserve rollbacks during scheduled OTA retries

Theo Browne committed 2 months ago

Commit a11cfa21 parent e7204ff2 files · +70 −9Browse files

Showing the changes to .github (1 of 2 files). Show all

Unified · Split

.github/workflows/mobile-eas-production.yml+24−6
@@ -69,11 +69,10 @@ on: · 68 unmodified lines
6969 schedule:
7070 - cron: "17,47 * * * *"
7171
72−# Serialize runs so OTAs publish in merge order. GitHub keeps at most one
73−# queued run per group, so a burst of merges collapses into one run of the
74−# newest commit — intermediate commits don't need their own OTA.
72+# Serialize push releases so OTAs publish in merge order. Scheduled retries
73+# use a separate group and cannot replace a queued push that must start builds.
7574 concurrency:
76− group: mobile-eas-production
75+ group: mobile-eas-production-${{ github.event_name == 'schedule' && 'scheduled' || 'release' }}
7776 cancel-in-progress: false
7877
7978 jobs:
@@ -277,9 +276,16 @@ jobs: · 197 unmodified lines
277276 matching="$(eas build:list --platform "$platform" --build-profile production --status finished --fingerprint-hash "$hash" --limit 1 --json --non-interactive | jq 'length')"
278277 if [ "$matching" -gt 0 ]; then
279278 if [ "$GITHUB_EVENT_NAME" = "schedule" ]; then
280− group="$(eas update:list --branch production --platform "$platform" --runtime-version "$hash" --limit 1 --json --non-interactive | jq -r '.currentPage[0].group // empty')"
279+ updates="$(eas update:list --branch production --platform "$platform" --runtime-version "$hash" --limit 2 --json --non-interactive)"
280+ group="$(jq -r '.currentPage[0].group // empty' <<< "$updates")"
281281 if [ -n "$group" ]; then
282− published_commit="$(eas update:view "$group" --json | jq -r --arg platform "$platform" '.[] | select(.platform == $platform) | .gitCommitHash // empty')"
282+ update="$(eas update:view "$group" --json | jq -c --arg platform "$platform" 'map(select(.platform == $platform)) | .[0] // {}')"
283+ if [ "$(jq -r '.isRollBackToEmbedded // false' <<< "$update")" = "true" ]; then
284+ echo "$platform: preserving production rollback to the embedded update"
285+ continue
286+ fi
287+
288+ published_commit="$(jq -r '.gitCommitHash // empty' <<< "$update")"
283289 if [ -n "$published_commit" ] &&
284290 git cat-file -e "$published_commit^{commit}" 2>/dev/null &&
285291 git -C "$(git rev-parse --show-toplevel)" diff --quiet "$published_commit" HEAD -- \
@@ -296,6 +302,18 @@ jobs: · 10 unmodified lines
296302 echo "$platform: production OTA already contains the latest mobile changes"
297303 continue
298304 fi
305+
306+ previous_group="$(jq -r '.currentPage[1].group // empty' <<< "$updates")"
307+ if [ -n "$published_commit" ] && [ -n "$previous_group" ]; then
308+ previous_commit="$(eas update:view "$previous_group" --json | jq -r --arg platform "$platform" '.[] | select(.platform == $platform) | .gitCommitHash // empty')"
309+ if [ -n "$previous_commit" ] &&
310+ [ "$published_commit" != "$previous_commit" ] &&
311+ git cat-file -e "$previous_commit^{commit}" 2>/dev/null &&
312+ git merge-base --is-ancestor "$published_commit" "$previous_commit"; then
313+ echo "$platform: preserving production rollback to an earlier update"
314+ continue
315+ fi
316+ fi
299317 fi
300318 fi
301319