diff --git a/action.bash b/action.bash index 4757b8e..bc5f573 100755 --- a/action.bash +++ b/action.bash @@ -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 @@ -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 diff --git a/action.yml b/action.yml index f2e75b1..7d983f1 100644 --- a/action.yml +++ b/action.yml @@ -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." @@ -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 }}