Skip to content

Commit

Permalink
Merge pull request #13 from jgehrcke/jp/fix-push-pull-loop
Browse files Browse the repository at this point in the history
entrypoint.sh: pull/push loop: leave upon success
  • Loading branch information
jgehrcke committed Apr 14, 2021
2 parents 715457d + 52979fb commit 0531cfb
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -188,17 +188,28 @@ do
exit 1
fi

set -x

# Do a pull right before the push, they should be looked at as an 'atomic
# unit', doing them right after one another is the recipe for long-term
# convergence here -- of course that means that even the first push is
# quite likely to succeed. Not sure if more than 1 loop iteration will
# ever be hit in the real world.
git pull
git push --set-upstream origin "${DATA_BRANCH_NAME}" || \
echo "push failed, retry soon"
set -x
git pull # error out if pull fails (errexit)

set +e
git push --set-upstream origin "${DATA_BRANCH_NAME}"
PUSH_ECODE=$?
set -e
set +x

if [ $PUSH_ECODE -ne 0 ]; then
echo "warn: git push returned with code ${PUSH_ECODE}, retry soon"
else
echo "pull/push loop: push succeeded, leave loop"
break
fi

echo "pull/push loop:sleep for 10 s"
sleep 10
done
Expand Down

0 comments on commit 0531cfb

Please sign in to comment.