From 2c9e17c9ab79b75cb752d076d6f8b25aa84a2774 Mon Sep 17 00:00:00 2001 From: Santiago Bernhardt Date: Thu, 5 Jan 2023 13:32:53 +1300 Subject: [PATCH] Exit with error if default branch is not set in non prs (#235) --- entrypoint.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/entrypoint.sh b/entrypoint.sh index 92cfa05a..ff408802 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -125,6 +125,20 @@ then exit 0 fi +# sanitize that the default_branch is set (via env var when running on PRs) else find it natively +if [ -z "${default_branch}" ] +then + echo "The DEFAULT_BRANCH should be autodetected when tag-action runs on on PRs else must be defined, See: https://github.com/anothrNick/github-tag-action/pull/230, since is not defined we find it natively" + default_branch=$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@') + echo "default_branch=${default_branch}" + # re check this + if [ -z "${default_branch}" ] + then + echo "::error::DEFAULT_BRANCH must not be null, something has gone wrong." + exit 1 + fi +fi + # get the merge commit message looking for #bumps declare -A history_type=( ["last"]="$(git show -s --format=%B)" \