Skip to content

Commit 8c8163e

Browse files
authored
Hotfix - Validate default_branch only when history type full (#244)
* validate default_branch when history type full * This var is branch_history * there is no head in the container hence we change the strategy for filtering * Add readme warning when combining history full without specifying the default branch an is not main or master
1 parent e286d60 commit 8c8163e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ _NOTE: set the fetch-depth for `actions/checkout@v2` or newer to be sure you ret
7575

7676
- **GITHUB_TOKEN** **_(required)_** - Required for permission to tag the repo.
7777
- **DEFAULT_BUMP** _(optional)_ - Which type of bump to use when none explicitly provided (default: `minor`).
78-
- **DEFAULT_BRANCH** _(optional)_ - Overwrite the default branch its read from Github Runner env var but can be overwritten (default: `$GITHUB_BASE_REF`).
78+
- **DEFAULT_BRANCH** _(optional)_ - Overwrite the default branch its read from Github Runner env var but can be overwritten (default: `$GITHUB_BASE_REF`). Strongly recommended to set this var if using anything else than master or main as default branch otherwise in combination with history full will error.
7979
- **WITH_V** _(optional)_ - Tag version with `v` character.
8080
- **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` ...
8181
- **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!**

entrypoint.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ then
126126
fi
127127

128128
# sanitize that the default_branch is set (via env var when running on PRs) else find it natively
129-
if [ -z "${default_branch}" ]
129+
if [ -z "${default_branch}" ] && [ "$branch_history" == "full" ]
130130
then
131131
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"
132-
default_branch=$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
132+
default_branch=$(git branch -rl '*/master' '*/main' | cut -d / -f2)
133133
echo "default_branch=${default_branch}"
134134
# re check this
135135
if [ -z "${default_branch}" ]

0 commit comments

Comments
 (0)