Skip to content

Commit db3664b

Browse files
committed
ci: add retry loop for parallel plugin registry pushes
1 parent ea9b083 commit db3664b

File tree

1 file changed

+37
-14
lines changed

1 file changed

+37
-14
lines changed

.github/workflows/build-plugin.yml

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ jobs:
223223
build/Plugins/${BUNDLE_NAME}-arm64.zip \
224224
build/Plugins/${BUNDLE_NAME}-x86_64.zip
225225
226-
# Update plugin registry
226+
# Update plugin registry (with retry to handle parallel pushes)
227227
if [ -n "${REGISTRY_DEPLOY_KEY:-}" ]; then
228228
ARM64_URL="https://github.com/${{ github.repository }}/releases/download/${TAG}/${BUNDLE_NAME}-arm64.zip"
229229
X86_64_URL="https://github.com/${{ github.repository }}/releases/download/${TAG}/${BUNDLE_NAME}-x86_64.zip"
@@ -234,14 +234,24 @@ jobs:
234234
235235
git clone git@github.com:datlechin/tablepro-plugins.git "$WORK/registry"
236236
cd "$WORK/registry"
237-
git pull --rebase origin main
238-
239-
python3 - \
240-
"$BUNDLE_ID" "$DISPLAY_NAME" "$VERSION" "$SUMMARY" \
241-
"$DB_TYPE_IDS" "$ARM64_URL" "$ARM64_SHA" \
242-
"$X86_64_URL" "$X86_SHA" "$MIN_APP_VERSION" \
243-
"$ICON" "$HOMEPAGE" "$CATEGORY" \
244-
<<'PYTHON_SCRIPT'
237+
git config user.name "github-actions[bot]"
238+
git config user.email "github-actions[bot]@users.noreply.github.com"
239+
240+
# Retry loop: pull latest, apply update, push — retry if another job pushed first
241+
MAX_RETRIES=10
242+
for attempt in $(seq 1 $MAX_RETRIES); do
243+
echo "Registry update attempt $attempt/$MAX_RETRIES"
244+
245+
# Reset any previous commit and pull latest
246+
git reset --hard origin/main
247+
git pull --rebase origin main
248+
249+
python3 - \
250+
"$BUNDLE_ID" "$DISPLAY_NAME" "$VERSION" "$SUMMARY" \
251+
"$DB_TYPE_IDS" "$ARM64_URL" "$ARM64_SHA" \
252+
"$X86_64_URL" "$X86_SHA" "$MIN_APP_VERSION" \
253+
"$ICON" "$HOMEPAGE" "$CATEGORY" \
254+
<<'PYTHON_SCRIPT'
245255
import json, sys
246256
247257
bundle_id, name, version, summary = sys.argv[1:5]
@@ -278,11 +288,24 @@ jobs:
278288
f.write("\n")
279289
PYTHON_SCRIPT
280290
281-
git config user.name "github-actions[bot]"
282-
git config user.email "github-actions[bot]@users.noreply.github.com"
283-
git add plugins.json
284-
git commit -m "Update $DISPLAY_NAME to v$VERSION"
285-
git push
291+
git add plugins.json
292+
git commit -m "Update $DISPLAY_NAME to v$VERSION"
293+
294+
if git push; then
295+
echo "Registry updated successfully on attempt $attempt"
296+
break
297+
fi
298+
299+
if [ "$attempt" -eq "$MAX_RETRIES" ]; then
300+
echo "::error::Failed to push registry update after $MAX_RETRIES attempts"
301+
exit 1
302+
fi
303+
304+
# Jittered backoff: 2-5s base + random to spread parallel retries
305+
DELAY=$((2 + RANDOM % 4))
306+
echo "Push rejected (concurrent update), retrying in ${DELAY}s..."
307+
sleep "$DELAY"
308+
done
286309
287310
ssh-add -D
288311
eval "$(ssh-agent -k)"

0 commit comments

Comments
 (0)