Merge pull request #125 from tj-actions/feat/support-default-branch-output

feat: add support for the default_branch output
This commit is contained in:
Tonye Jack 2022-03-22 17:16:35 -04:00 committed by GitHub
commit 9bc7d378ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 2 deletions

View File

@ -17,7 +17,7 @@ jobs:
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, windows-latest, macos-latest, macos-11, ubuntu-18.04, windows-2022, windows-2016]
platform: [ubuntu-latest, windows-latest, macos-latest, macos-11, ubuntu-18.04, windows-2022]
steps:
- name: Checkout
@ -27,6 +27,7 @@ jobs:
uses: ./
- name: Show output
run: |
echo "Default Branch: ${{ steps.branch-name.outputs.default_branch }}"
echo "Current Branch: ${{ steps.branch-name.outputs.current_branch }}"
echo "Base Ref: ${{ steps.branch-name.outputs.base_ref_branch }}"
echo "Head Ref: ${{ steps.branch-name.outputs.head_ref_branch }}"

View File

@ -12,6 +12,9 @@ jobs:
- uses: actions/checkout@v3.0.0
with:
fetch-depth: 0
- name: Run auto-doc
uses: tj-actions/auto-doc@v1.2.14
- name: Run test
uses: tj-actions/remark@v3

View File

@ -3,7 +3,7 @@ description: Retrieve giithub branch or tag information without the /ref/* prefi
author: tj-actions
inputs:
strip_tag_prefix:
description: 'The tag prefix to strip i.e v0.0.1 -> (strip v) -> 0.0.1'
description: 'The tag prefix to strip e.g v0.0.1 -> (strip v) -> 0.0.1'
default: ''
required: false
@ -14,6 +14,8 @@ outputs:
is_tag:
value: ${{ steps.tag.outputs.is_tag }}
description: 'Returns "true" if the current branch is a tag else "false".'
default_branch:
value: ${{ steps.default.outputs.default_branch }}
current_branch:
value: ${{ steps.current_branch.outputs.current_branch }}
description: 'Returns the value of the current branch which is consistent regardless of event_type: i.e (push, pull_requests).'
@ -72,8 +74,10 @@ runs:
if [[ "${{ github.ref }}" != "refs/tags/"* ]]; then
if [[ "${{ steps.current_branch.outputs.current_branch }}" == "${{ steps.branch.outputs.ref_branch }}" ]]; then
echo "::set-output name=is_default::true"
echo "::set-output name=default_branch::${{ github.event.repository.default_branch }}"
else
echo "::set-output name=is_default::false"
echo "::set-output name=default_branch::${{ github.event.repository.default_branch }}"
fi
fi
shell: bash