File tree Expand file tree Collapse file tree 2 files changed +54
-6
lines changed Expand file tree Collapse file tree 2 files changed +54
-6
lines changed Original file line number Diff line number Diff line change @@ -71,13 +71,37 @@ jobs:
7171 RATIO=$(awk "BEGIN {printf \"%.1f\", ($COMPRESSED_SIZE / $ORIGINAL_SIZE) * 100}")
7272 echo "Compression: ${ORIGINAL_SIZE} bytes -> ${COMPRESSED_SIZE} bytes (${RATIO}%)"
7373
74- # Commit and push
74+ # Commit and push with retry logic
7575 cd /tmp/searchindex-repo
7676 git config user.name "GitHub Actions"
7777 git config user.email "[email protected] " 7878 git add "${FILENAME}" "${FILENAME}.gz"
79- git commit -m "Update ${FILENAME} from hacktricks-cloud build" || echo "No changes to commit"
80- git push || echo "No changes to push"
79+
80+ if git diff --staged --quiet; then
81+ echo "No changes to commit"
82+ else
83+ git commit -m "Update ${FILENAME} from hacktricks-cloud build"
84+
85+ # Retry push up to 20 times with pull --rebase between attempts
86+ MAX_RETRIES=20
87+ RETRY_COUNT=0
88+ while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
89+ if git push origin main; then
90+ echo "Successfully pushed on attempt $((RETRY_COUNT + 1))"
91+ break
92+ else
93+ RETRY_COUNT=$((RETRY_COUNT + 1))
94+ if [ $RETRY_COUNT -lt $MAX_RETRIES ]; then
95+ echo "Push failed, attempt $RETRY_COUNT/$MAX_RETRIES. Pulling and retrying..."
96+ git pull --rebase origin main
97+ sleep $((RETRY_COUNT * 2)) # Exponential backoff
98+ else
99+ echo "Failed to push after $MAX_RETRIES attempts"
100+ exit 1
101+ fi
102+ fi
103+ done
104+ fi
81105
82106 # Login in AWs
83107 - name : Configure AWS credentials using OIDC
Original file line number Diff line number Diff line change @@ -180,13 +180,37 @@ jobs:
180180 RATIO=$(awk "BEGIN {printf \"%.1f\", ($COMPRESSED_SIZE / $ORIGINAL_SIZE) * 100}")
181181 echo "Compression: ${ORIGINAL_SIZE} bytes -> ${COMPRESSED_SIZE} bytes (${RATIO}%)"
182182
183- # Commit and push
183+ # Commit and push with retry logic
184184 cd /tmp/searchindex-repo
185185 git config user.name "GitHub Actions"
186186 git config user.email "[email protected] " 187187 git add "${FILENAME}" "${FILENAME}.gz"
188- git commit -m "Update ${FILENAME} from hacktricks-cloud build" || echo "No changes to commit"
189- git push || echo "No changes to push"
188+
189+ if git diff --staged --quiet; then
190+ echo "No changes to commit"
191+ else
192+ git commit -m "Update ${FILENAME} from hacktricks-cloud build"
193+
194+ # Retry push up to 20 times with pull --rebase between attempts
195+ MAX_RETRIES=20
196+ RETRY_COUNT=0
197+ while [ $RETRY_COUNT -lt $MAX_RETRIES ]; do
198+ if git push origin main; then
199+ echo "Successfully pushed on attempt $((RETRY_COUNT + 1))"
200+ break
201+ else
202+ RETRY_COUNT=$((RETRY_COUNT + 1))
203+ if [ $RETRY_COUNT -lt $MAX_RETRIES ]; then
204+ echo "Push failed, attempt $RETRY_COUNT/$MAX_RETRIES. Pulling and retrying..."
205+ git pull --rebase origin main
206+ sleep $((RETRY_COUNT * 2)) # Exponential backoff
207+ else
208+ echo "Failed to push after $MAX_RETRIES attempts"
209+ exit 1
210+ fi
211+ fi
212+ done
213+ fi
190214
191215 # Login in AWs
192216 - name : Configure AWS credentials using OIDC
You can’t perform that action at this time.
0 commit comments