jamesfredley commented on code in PR #67:
URL: 
https://github.com/apache/grails-github-actions/pull/67#discussion_r2969980681


##########
deploy-github-pages/entrypoint.sh:
##########
@@ -316,6 +316,21 @@ git status
 
 echo "Committing changes."
 git commit -m "Deploying to documentation branch - $(date +"%T")" --quiet 
--allow-empty
-git push "${GIT_REPO_URL}" "${DOCUMENTATION_BRANCH}"
-echo "Deployment successful!"
+
+MAX_PUSH_ATTEMPTS=5
+PUSH_ATTEMPT=1
+while [ $PUSH_ATTEMPT -le $MAX_PUSH_ATTEMPTS ]; do
+  echo "Push attempt ${PUSH_ATTEMPT}/${MAX_PUSH_ATTEMPTS}"
+  if git push "${GIT_REPO_URL}" "${DOCUMENTATION_BRANCH}" 2>&1; then

Review Comment:
   Good catch - the `2>&1` serves no purpose here since we only check the exit 
code via the `if` condition. Removed in c4a92cf.



##########
deploy-github-pages/entrypoint.sh:
##########
@@ -316,6 +316,21 @@ git status
 
 echo "Committing changes."
 git commit -m "Deploying to documentation branch - $(date +"%T")" --quiet 
--allow-empty
-git push "${GIT_REPO_URL}" "${DOCUMENTATION_BRANCH}"
-echo "Deployment successful!"
+
+MAX_PUSH_ATTEMPTS=5
+PUSH_ATTEMPT=1
+while [ $PUSH_ATTEMPT -le $MAX_PUSH_ATTEMPTS ]; do
+  echo "Push attempt ${PUSH_ATTEMPT}/${MAX_PUSH_ATTEMPTS}"
+  if git push "${GIT_REPO_URL}" "${DOCUMENTATION_BRANCH}" 2>&1; then
+    echo "Deployment successful!"
+    break
+  fi
+  if [ $PUSH_ATTEMPT -eq $MAX_PUSH_ATTEMPTS ]; then
+    echo "ERROR: Push failed after ${MAX_PUSH_ATTEMPTS} attempts." >&2
+    exit 1
+  fi
+  echo "Push rejected, pulling remote changes and retrying..."
+  git pull --rebase "${GIT_REPO_URL}" "${DOCUMENTATION_BRANCH}"

Review Comment:
   Good suggestion - added incremental backoff with jitter in c4a92cf. Uses 
`(attempt * 2) + (random 0-2)` seconds, so retries wait ~4-6s, ~6-8s, ~8-10s, 
~10-12s. This should break the lockstep when multiple branch doc deploys race.



##########
deploy-github-pages/entrypoint.sh:
##########
@@ -316,6 +316,21 @@ git status
 
 echo "Committing changes."
 git commit -m "Deploying to documentation branch - $(date +"%T")" --quiet 
--allow-empty
-git push "${GIT_REPO_URL}" "${DOCUMENTATION_BRANCH}"
-echo "Deployment successful!"
+
+MAX_PUSH_ATTEMPTS=5
+PUSH_ATTEMPT=1
+while [ $PUSH_ATTEMPT -le $MAX_PUSH_ATTEMPTS ]; do
+  echo "Push attempt ${PUSH_ATTEMPT}/${MAX_PUSH_ATTEMPTS}"
+  if git push "${GIT_REPO_URL}" "${DOCUMENTATION_BRANCH}" 2>&1; then
+    echo "Deployment successful!"
+    break
+  fi

Review Comment:
   In this CI context, auth is pre-configured via `GH_TOKEN`/`GITHUB_TOKEN` and 
the refspec is validated upstream. The only realistic failure mode is 
concurrent push rejection. If auth/network fails, it would also fail on the 
subsequent `pull --rebase`, exhaust retries, and exit 1 with the actual git 
error visible in the CI log. Adding error classification to a bash deployment 
script adds complexity without meaningful benefit here.



##########
deploy-github-pages/entrypoint.sh:
##########
@@ -316,6 +316,21 @@ git status
 
 echo "Committing changes."
 git commit -m "Deploying to documentation branch - $(date +"%T")" --quiet 
--allow-empty
-git push "${GIT_REPO_URL}" "${DOCUMENTATION_BRANCH}"
-echo "Deployment successful!"
+
+MAX_PUSH_ATTEMPTS=5
+PUSH_ATTEMPT=1
+while [ $PUSH_ATTEMPT -le $MAX_PUSH_ATTEMPTS ]; do
+  echo "Push attempt ${PUSH_ATTEMPT}/${MAX_PUSH_ATTEMPTS}"
+  if git push "${GIT_REPO_URL}" "${DOCUMENTATION_BRANCH}" 2>&1; then
+    echo "Deployment successful!"
+    break
+  fi
+  if [ $PUSH_ATTEMPT -eq $MAX_PUSH_ATTEMPTS ]; then
+    echo "ERROR: Push failed after ${MAX_PUSH_ATTEMPTS} attempts." >&2
+    exit 1
+  fi
+  echo "Push rejected, pulling remote changes and retrying..."
+  git pull --rebase "${GIT_REPO_URL}" "${DOCUMENTATION_BRANCH}"
+  PUSH_ATTEMPT=$((PUSH_ATTEMPT + 1))

Review Comment:
   The actual git error output is already visible in the CI log above the "Push 
rejected" message, so the failure reason is never hidden. The message is 
descriptive enough for this CI-only script. If a non-rejection error occurs, 
retries exhaust and exit 1 with the real error visible.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to