From 892c80ceeff6234cd58701b5fea41e43b0398048 Mon Sep 17 00:00:00 2001 From: Pete Houston Date: Wed, 21 Apr 2021 16:30:35 -0500 Subject: [PATCH] Update to 1.2 --- README.md | 34 +++++++++++++++++++++++++++++++--- package.json | 2 +- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3c73544..9dfa23e 100644 --- a/README.md +++ b/README.md @@ -8,22 +8,34 @@ Get pure Git branch name without `***/ref/` prefix. **Required** The environment variable name to export, ex. `CURRENT_BRANCH`, `GIT_BRANCH`. Default `"GIT_BRANCH_NAME"`. +On `pull_request` event, two additional environment variables are exported for `HEAD` and `BASE`. The env names are suffixed with `_HEAD` and `_BASE`. By default, they are `GIT_BRANCH_NAME_HEAD` and `GIT_BRANCH_NAME_BASE`. + ## Outputs ### `git_branch_name` The current Git branch name. +On `pull_request` event, it is the same as `git_branch_name_head`. + +### `git_branch_name_head` + +The current Git branch name at `HEAD`. Only available on `pull_request` event. + +### `git_branch_name_base` + +The current Git branch name at `BASE`. Only available on `pull_request` event. + ## Example usage Export to default environment variable `GIT_BRANCH_NAME`. ```yaml -uses: petehouston/github-actions-query-branch-name@v1.1 +uses: petehouston/github-actions-query-branch-name@v1.2 ``` Export to custom environment variable, ex. `MY_BRANCH` ```yaml -uses: petehouston/github-actions-query-branch-name@v1.1 +uses: petehouston/github-actions-query-branch-name@v1.2 with: name: MY_BRANCH ``` @@ -31,10 +43,26 @@ with: Get branch name from output. ```yaml - name: Query Git branch name - uses: petehouston/github-actions-query-branch-name@v1.1 + uses: petehouston/github-actions-query-branch-name@v1.2 id: queryBranch - name: Get Git branch name run: |- echo "GIT_BRANCH_NAME = $GIT_BRANCH_NAME" echo "Branch name: ${{ steps.queryBranch.outputs.git_branch_name }}" ``` + +Get branch name from `pull_request`. +```yaml +- name: Query Git branch name + uses: petehouston/github-actions-query-branch-name@v1.2 + id: queryBranch +- name: Get Git branch name only on pull request + if: github.event_name == 'pull_request' + run: |- + echo "GIT_BRANCH_NAME = $GIT_BRANCH_NAME" + echo "GIT_BRANCH_NAME_HEAD = $GIT_BRANCH_NAME_BEAD" + echo "GIT_BRANCH_NAME_BASE = $GIT_BRANCH_NAME_BASE" + echo "Branch name: ${{ steps.queryBranch.outputs.git_branch_name }}" + echo "Branch name: ${{ steps.queryBranch.outputs.git_branch_name_head }}" + echo "Branch name: ${{ steps.queryBranch.outputs.git_branch_name_base }}" +``` diff --git a/package.json b/package.json index eafbdd4..ff11b8d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "github-actions-query-branch-name", - "version": "1.1.0", + "version": "1.2.0", "description": "Get pure Git branch name without ref/ prefix", "main": "dist/index.js", "scripts": {