Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jackton1 committed May 27, 2021
1 parent 83d2546 commit 6f85513
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ Get branch or tag information without the `/ref/*` prefix
| Output | type | Example | Description |
|:--------------------:|:------------:|:---------------------------:|:-----------------------------------------------------------------:|
| is_default | `boolean` | `true` *OR* `false` | Detects wheter the action is running on a default branch |
| is_tag | `boolean` | `true` *OR* `false` | Detects wheter the action is running on a tag branch |
| current_branch | `string` | `main` *OR* `feature/test` | Always returns a valid branch name for a triggered 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 |
| tag | `string` | `v0.0.1` *OR* `0.0.1` | The tag that triggered the workflow run |
| tag | `string` | `v0.0.1` *OR* `0.0.1` | The tag that triggered the workflow run |


## Inputs
Expand All @@ -28,7 +29,6 @@ Get branch or tag information without the `/ref/*` prefix
```yaml
...
steps:
- uses: actions/checkout@v2
- name: Get branch names
id: branch-name
uses: tj-actions/branch-names@v4.2
Expand All @@ -39,11 +39,10 @@ Get branch or tag information without the `/ref/*` prefix
```yaml
...
steps:
- uses: actions/checkout@v2
- name: Get branch names
id: branch-name
uses: tj-actions/branch-names@v4.2

- name: Running on the default branch.
if: steps.branch-name.outputs.is_default == 'true'
run: |
Expand All @@ -55,6 +54,24 @@ Get branch or tag information without the `/ref/*` prefix
run: |
echo "Running on pr: ${{ steps.branch-name.outputs.current_branch }}"
# Outputs: "Running on pr: feature/test".

- name: Running on a tag branch.
if: steps.branch-name.outputs.is_tag == 'true'
run: |
echo "Running on tag: ${{ steps.branch-name.outputs.tag }}"
# Outputs: "Running on tag: v0.0.1".

- name: Running on a non tag based branch and the default branch.
if: steps.branch-name.outputs.is_tag == 'false' && steps.branch-name.outputs.is_default == 'true'
run: |
echo "Running on branch: ${{ steps.branch-name.outputs.current_branch }}"
# Outputs: "Running on branch: main".

- name: Running on a non tag based branch and a PR branch.
if: steps.branch-name.outputs.is_tag == 'false' && steps.branch-name.outputs.is_default == 'false'
run: |
echo "Running on branch: ${{ steps.branch-name.outputs.current_branch }}"
# Outputs: "Running on branch: feature/test".

- name: Current branch name
if: github.event_name == 'pull_request'
Expand Down Expand Up @@ -114,6 +131,8 @@ on:
```




* Free software: [MIT license](LICENSE)


Expand Down

0 comments on commit 6f85513

Please sign in to comment.