Skip to content

Commit

Permalink
use default branch by default, also support master branch alias
Browse files Browse the repository at this point in the history
  • Loading branch information
balupton committed Nov 23, 2020
1 parent 492cd22 commit 2811aea
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
9 changes: 8 additions & 1 deletion action.bash
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ set -ueE -o pipefail
# MANUAL GITHUB CONTEXT VARIABLES
# https://docs.github.com/en/free-pro-team@latest/actions/reference/context-and-expression-syntax-for-github-actions

# GH_EVENT_NAME: ${{github.event_name}}
# GH_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
# GH_MASTER_BRANCH: ${{ github.event.repository.master_branch }}
# GH_EVENT_NAME: ${{ github.event_name }}

# =====================================
# MANUAL ENVIRONMENT VARIABLES
Expand Down Expand Up @@ -71,6 +73,11 @@ echo "logged into npm as: $(npm whoami)"
# check if we wish to tag the current branch
if test -n "${NPM_BRANCH_TAG:-}"; then
branch="${NPM_BRANCH_TAG%:*}"
if test -z "$branch" -o "$branch" = "default"; then
branch="${GH_DEFAULT_BRANCH}"
elif test "$branch" = "master"; then
branch="${GH_MASTER_BRANCH}"
fi
if test "$branch" = "$REPO_BRANCH"; then
tag="${NPM_BRANCH_TAG#*:}"
fi
Expand Down
12 changes: 7 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ inputs:
description: "Specify the token to authorize the publishing of releases to npm."
required: true
npmBranchTag:
description: "If you wish for each new commit to particular branch to be published to a particular npm tag, then specify it like so `branch:tag`, e.g. `main:next`."
description: "If you wish for each new commit to particular branch to be published to a particular npm tag, then specify it like so `branch:tag`, e.g. `main:next`. Omitting the branch like so `:next` will use the default branch. Using `master` as the branch will use the master branch as reported by GitHub. Using `default` as the branch will use the default branch as reported by GitHub."
required: false
bevryCDNToken:
description: "If you wish to map your npm release to the Bevry CDN, then provide your Bevry CDN token."
Expand All @@ -25,7 +25,9 @@ runs:
- run: $GITHUB_ACTION_PATH/action.bash
shell: bash
env:
GH_EVENT_NAME: ${{github.event_name}}
NPM_AUTH_TOKEN: ${{inputs.npmAuthToken}}
NPM_BRANCH_TAG: ${{inputs.npmBranchTag}}
BEVRY_CDN_TOKEN: ${{inputs.bevryCDNToken}}
GH_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
GH_MASTER_BRANCH: ${{ github.event.repository.master_branch }}
GH_EVENT_NAME: ${{ github.event_name }}
NPM_AUTH_TOKEN: ${{ inputs.npmAuthToken }}
NPM_BRANCH_TAG: ${{ inputs.npmBranchTag }}
BEVRY_CDN_TOKEN: ${{ inputs.bevryCDNToken }}

0 comments on commit 2811aea

Please sign in to comment.