From 215ab1c6f517778fb7cf45fe1468ffd95a5c4460 Mon Sep 17 00:00:00 2001 From: georeith Date: Fri, 6 Sep 2024 07:40:32 +0100 Subject: [PATCH] fix: check out correct branch on pull_request events (#244) * fix: check out correct branch on pull_request events * fix: work with tags event --- entrypoint.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 588b6e1..d02ead8 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -229,8 +229,11 @@ push_to_branch() { git config --global user.email "${INPUT_GITHUB_USER_EMAIL}" git config --global user.name "${INPUT_GITHUB_USER_NAME}" - if [ "$INPUT_SKIP_REF_CHECKOUT" != true ] && [ ${GITHUB_REF#refs/heads/} != $GITHUB_REF ]; then - git checkout "${GITHUB_REF#refs/heads/}" + if [ "$INPUT_SKIP_REF_CHECKOUT" != true ]; then + CHECKOUT=${GITHUB_HEAD_REF:-${GITHUB_REF}} + CHECKOUT=${CHECKOUT#refs/heads/} + CHECKOUT=${CHECKOUT#refs/tags/} + git checkout "${CHECKOUT}" fi if [ -n "$(git show-ref refs/heads/${BRANCH})" ]; then