From bd09bab9c37f6afa9fda27ed710384c83101bcfe Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sun, 7 Feb 2021 19:45:09 -0500 Subject: [PATCH] Update README.md --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 8782583..fee62d8 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,19 @@ Get branch information without the `/ref/*` prefix - name: Get branch names uses: tj-actions/branch-names@v2 id: branch-names + + - name: Current branch name + if: github.event_name == 'pull_request' + run: | + echo "${{ steps.branch-name.outputs.current_branch }}" + # Outputs: "feature/test" current PR branch. + + - name: Current branch name + if: github.event_name == 'push' + run: | + echo "${{ steps.branch-name.outputs.current_branch }}" + # Outputs: "main" the current branch that triggered the action. + - name: Get Ref brach name run: | echo "${{ steps.branch-name.outputs.ref_branch }}" @@ -28,6 +41,7 @@ Get branch information without the `/ref/*` prefix run: | echo "${{ steps.branch-name.outputs.base_ref_branch }}" # Outputs: "main" for main <- PR branch. + ``` @@ -65,6 +79,7 @@ on: | Output | type | Example | Description | |:--------------------:|:-----------:|:---------------------:|:------------------------------------------------:| +| current_branch | `string` | `main` | Always returns the branch that triggered the workflow run. | | base_ref_branch | `string` | `main` | The target branch of a pull request | | head_ref_branch | `string` | `feature/test` | The source branch of a pull request | | ref_branch | `string` | `1/merge` OR `main` | The branch that triggered the workflow run |