Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

👷 ci: retry overlay Git operations after App token creation (#21694)

Inneie73b65d47cce
diff --git a/.github/actions/business-overlay/action.yml b/.github/actions/business-overlay/action.yml
index 5cd209be938..a9a14f5c07b 100644
--- a/.github/actions/business-overlay/action.yml
+++ b/.github/actions/business-overlay/action.yml
@@ -43,9 +43,9 @@ runs:
rm -rf "$overlay_checkout"
- git clone --depth 1 --no-checkout "https://x-access-token:${OVERLAY_TOKEN}@github.com/${OVERLAY_REPOSITORY}.git" "$overlay_checkout"
+ bash "$GITHUB_ACTION_PATH/../../scripts/gitWithRetry.sh" clone --depth 1 --no-checkout "https://x-access-token:${OVERLAY_TOKEN}@github.com/${OVERLAY_REPOSITORY}.git" "$overlay_checkout"
if [ -n "$OVERLAY_REF_INPUT" ]; then
- git -C "$overlay_checkout" fetch --depth 1 origin "$OVERLAY_REF_INPUT"
+ bash "$GITHUB_ACTION_PATH/../../scripts/gitWithRetry.sh" -C "$overlay_checkout" fetch --depth 1 origin "$OVERLAY_REF_INPUT"
git -C "$overlay_checkout" checkout --detach FETCH_HEAD
else
git -C "$overlay_checkout" checkout --detach
diff --git a/.github/actions/desktop-build-setup/action.yml b/.github/actions/desktop-build-setup/action.yml
index e8611260e89..830159bd906 100644
--- a/.github/actions/desktop-build-setup/action.yml
+++ b/.github/actions/desktop-build-setup/action.yml
@@ -47,9 +47,9 @@ runs:
rm -rf "$cloud_checkout"
- git clone --depth 1 --no-checkout "https://x-access-token:${CLOUD_TOKEN}@github.com/${CLOUD_REPOSITORY}.git" "$cloud_checkout"
+ bash "$GITHUB_ACTION_PATH/../../scripts/gitWithRetry.sh" clone --depth 1 --no-checkout "https://x-access-token:${CLOUD_TOKEN}@github.com/${CLOUD_REPOSITORY}.git" "$cloud_checkout"
if [ -n "$CLOUD_REF" ]; then
- git -C "$cloud_checkout" fetch --depth 1 origin "$CLOUD_REF"
+ bash "$GITHUB_ACTION_PATH/../../scripts/gitWithRetry.sh" -C "$cloud_checkout" fetch --depth 1 origin "$CLOUD_REF"
git -C "$cloud_checkout" checkout --detach FETCH_HEAD
else
git -C "$cloud_checkout" checkout --detach
diff --git a/.github/scripts/gitWithRetry.sh b/.github/scripts/gitWithRetry.sh
new file mode 100644
index 00000000000..603de07277b
--- /dev/null
+++ b/.github/scripts/gitWithRetry.sh
@@ -0,0 +1,18 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+# A freshly minted App token can reach GitHub's Git backend before its authorization does.
+status=0
+for delay in 0 3 10 30; do
+ if [ "$delay" -gt 0 ]; then
+ echo "::warning::Git request failed; retrying in ${delay}s to allow GitHub App token propagation." >&2
+ sleep "$delay"
+ fi
+ if git "$@"; then
+ exit 0
+ else
+ status=$?
+ fi
+done
+
+exit "$status"
diff --git a/.github/workflows/release-desktop-core-ota.yml b/.github/workflows/release-desktop-core-ota.yml
index baad41e2847..32636d1f50a 100644
--- a/.github/workflows/release-desktop-core-ota.yml
+++ b/.github/workflows/release-desktop-core-ota.yml
@@ -272,7 +272,7 @@ jobs:
run: |
set -euo pipefail
: "${CLOUD_REPOSITORY:?OVERLAY_REPOSITORY repository variable is not set}"
- cloud_ref=$(git -c http.https://github.com/.extraheader= ls-remote "https://x-access-token:${CLOUD_TOKEN}@github.com/${CLOUD_REPOSITORY}.git" HEAD | cut -f1)
+ cloud_ref=$(bash "$GITHUB_WORKSPACE/.github/scripts/gitWithRetry.sh" -c http.https://github.com/.extraheader= ls-remote "https://x-access-token:${CLOUD_TOKEN}@github.com/${CLOUD_REPOSITORY}.git" HEAD | cut -f1)
if [[ ! "$cloud_ref" =~ ^[0-9a-f]{40}$ ]]; then
echo "Unable to resolve Cloud revision"
exit 1