From bb3766ad6abf5b7209c3284683821505139e5065 Mon Sep 17 00:00:00 2001 From: Elliot Date: Fri, 2 Sep 2022 10:53:40 +0100 Subject: [PATCH] Add atomic push Since time elapses between the checkout the github workflow performs and the eventual push this action invokes the remote HEAD may have changed. If this is the case the HEAD update will be rejected but any tag (and their commits) will be pushed. In general I think this operation should be atomic, either we push everything or we push nothing. Force pushes still work the way you would expect (i.e. if we force the HEAD update with --atomic everything is still pushed) This also protects from the situation where someone else has seized your tag name in the meantime but not updated your HEAD. See git docs for more information - https://git-scm.com/docs/git-push#Documentation/git-push.txt---no-atomic --- start.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/start.sh b/start.sh index 1bbc320..bf8c48a 100755 --- a/start.sh +++ b/start.sh @@ -43,8 +43,8 @@ fi git config --local --add safe.directory ${INPUT_DIRECTORY} if ${INPUT_FORCE_WITH_LEASE}; then - git push --follow-tags $_FORCE_OPTION $_TAGS; + git push --atomic --follow-tags $_FORCE_OPTION $_TAGS; else - git push "${remote_repo}" HEAD:${INPUT_BRANCH} --verbose --follow-tags $_FORCE_OPTION $_TAGS; + git push "${remote_repo}" HEAD:${INPUT_BRANCH} --atomic --verbose --follow-tags $_FORCE_OPTION $_TAGS; fi