From a1e67da3cd565a18ee151d37c277e57a581753dd Mon Sep 17 00:00:00 2001 From: carlospolop Date: Sat, 4 Oct 2025 01:18:23 +0200 Subject: [PATCH] f --- .github/workflows/build_master.yml | 30 ++++++++++++++++++++++++++--- .github/workflows/translate_all.yml | 30 ++++++++++++++++++++++++++--- 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build_master.yml b/.github/workflows/build_master.yml index fc47d4c23..63dcafd9b 100644 --- a/.github/workflows/build_master.yml +++ b/.github/workflows/build_master.yml @@ -71,13 +71,37 @@ jobs: RATIO=$(awk "BEGIN {printf \"%.1f\", ($COMPRESSED_SIZE / $ORIGINAL_SIZE) * 100}") echo "Compression: ${ORIGINAL_SIZE} bytes -> ${COMPRESSED_SIZE} bytes (${RATIO}%)" - # Commit and push + # Commit and push with retry logic cd /tmp/searchindex-repo git config user.name "GitHub Actions" git config user.email "github-actions@github.com" git add "${FILENAME}" "${FILENAME}.gz" - git commit -m "Update ${FILENAME} from hacktricks-cloud build" || echo "No changes to commit" - git push || echo "No changes to push" + + if git diff --staged --quiet; then + echo "No changes to commit" + else + git commit -m "Update ${FILENAME} from hacktricks-cloud build" + + # Retry push up to 20 times with pull --rebase between attempts + MAX_RETRIES=20 + RETRY_COUNT=0 + while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do + if git push origin main; then + echo "Successfully pushed on attempt $((RETRY_COUNT + 1))" + break + else + RETRY_COUNT=$((RETRY_COUNT + 1)) + if [ $RETRY_COUNT -lt $MAX_RETRIES ]; then + echo "Push failed, attempt $RETRY_COUNT/$MAX_RETRIES. Pulling and retrying..." + git pull --rebase origin main + sleep $((RETRY_COUNT * 2)) # Exponential backoff + else + echo "Failed to push after $MAX_RETRIES attempts" + exit 1 + fi + fi + done + fi # Login in AWs - name: Configure AWS credentials using OIDC diff --git a/.github/workflows/translate_all.yml b/.github/workflows/translate_all.yml index 512c9fa46..2e6b222d7 100644 --- a/.github/workflows/translate_all.yml +++ b/.github/workflows/translate_all.yml @@ -180,13 +180,37 @@ jobs: RATIO=$(awk "BEGIN {printf \"%.1f\", ($COMPRESSED_SIZE / $ORIGINAL_SIZE) * 100}") echo "Compression: ${ORIGINAL_SIZE} bytes -> ${COMPRESSED_SIZE} bytes (${RATIO}%)" - # Commit and push + # Commit and push with retry logic cd /tmp/searchindex-repo git config user.name "GitHub Actions" git config user.email "github-actions@github.com" git add "${FILENAME}" "${FILENAME}.gz" - git commit -m "Update ${FILENAME} from hacktricks-cloud build" || echo "No changes to commit" - git push || echo "No changes to push" + + if git diff --staged --quiet; then + echo "No changes to commit" + else + git commit -m "Update ${FILENAME} from hacktricks-cloud build" + + # Retry push up to 20 times with pull --rebase between attempts + MAX_RETRIES=20 + RETRY_COUNT=0 + while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do + if git push origin main; then + echo "Successfully pushed on attempt $((RETRY_COUNT + 1))" + break + else + RETRY_COUNT=$((RETRY_COUNT + 1)) + if [ $RETRY_COUNT -lt $MAX_RETRIES ]; then + echo "Push failed, attempt $RETRY_COUNT/$MAX_RETRIES. Pulling and retrying..." + git pull --rebase origin main + sleep $((RETRY_COUNT * 2)) # Exponential backoff + else + echo "Failed to push after $MAX_RETRIES attempts" + exit 1 + fi + fi + done + fi # Login in AWs - name: Configure AWS credentials using OIDC