Skip to content

Commit

Permalink
Hotfix - Validate default_branch only when history type full (#244)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
sbe-arg committed Jan 6, 2023
1 parent e286d60 commit 8c8163e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -75,7 +75,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`).
- **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.
- **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!**
Expand Down
4 changes: 2 additions & 2 deletions entrypoint.sh
Expand Up @@ -126,10 +126,10 @@ then
fi

# sanitize that the default_branch is set (via env var when running on PRs) else find it natively
if [ -z "${default_branch}" ]
if [ -z "${default_branch}" ] && [ "$branch_history" == "full" ]
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/@@')
default_branch=$(git branch -rl '*/master' '*/main' | cut -d / -f2)
echo "default_branch=${default_branch}"
# re check this
if [ -z "${default_branch}" ]
Expand Down

0 comments on commit 8c8163e

Please sign in to comment.