From 172098fd43f4c6383c4babeaa59d5d967eab18c4 Mon Sep 17 00:00:00 2001 From: Santiago Bernhardt Date: Tue, 3 Jan 2023 12:34:07 +1300 Subject: [PATCH] Fix: Get the default branch from env vars also allow to overwrite as parameter (#230) --- README.md | 1 + entrypoint.sh | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9fb029d..36260c4 100755 --- a/README.md +++ b/README.md @@ -69,6 +69,7 @@ _NOTE: set the fetch-depth for `actions/checkout@v2` or newer to be sure you ret - **GITHUB_TOKEN** **_(required)_** - Required for permission to tag the repo. - **DEFAULT_BUMP** _(optional)_ - Which type of bump to use when none explicitly provided (default: `minor`). +- **DEFAULT_BRANCH** _(optional)_ - Overwrite the default branch its read from Github Runner env var but can be overwritten (default: `$GITHUB_BASE_REF`). - **WITH_V** _(optional)_ - Tag version with `v` character. - **RELEASE_BRANCHES** _(optional)_ - Comma separated list of branches (bash reg exp accepted) that will generate the release tags. Other branches and pull-requests generate versions postfixed with the commit hash and do not generate any tag. Examples: `master` or `.*` or `release.*,hotfix.*,master` ... - **CUSTOM_TAG** _(optional)_ - Set a custom tag, useful when generating tag based on f.ex FROM image in a docker image. **Setting this tag will invalidate any other settings set!** diff --git a/entrypoint.sh b/entrypoint.sh index d5e0023..10e1731 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -4,6 +4,7 @@ set -o pipefail # config default_semvar_bump=${DEFAULT_BUMP:-minor} +default_branch=${DEFAULT_BRANCH:-$GITHUB_BASE_REF} # get the default branch from github runner env vars with_v=${WITH_V:-false} release_branches=${RELEASE_BRANCHES:-master,main} custom_tag=${CUSTOM_TAG:-} @@ -26,6 +27,7 @@ cd "${GITHUB_WORKSPACE}/${source}" || exit 1 echo "*** CONFIGURATION ***" echo -e "\tDEFAULT_BUMP: ${default_semvar_bump}" +echo -e "\tDEFAULT_BRANCH: ${default_branch}" echo -e "\tWITH_V: ${with_v}" echo -e "\tRELEASE_BRANCHES: ${release_branches}" echo -e "\tCUSTOM_TAG: ${custom_tag}" @@ -127,7 +129,7 @@ fi # get the merge commit message looking for #bumps declare -A history_type=( ["last"]="$(git show -s --format=%B)" \ - ["full"]="$(git log master..HEAD --format=%B)" \ + ["full"]="$(git log "${default_branch}"..HEAD --format=%B)" \ ) log=${history_type[${branch_history}]} printf "History:\n---\n%s\n---\n" "$log"