mirror of
https://github.com/tj-actions/branch-names.git
synced 2024-12-27 14:27:59 +08:00
Merge pull request #168 from tj-actions/feat/add-support-for-setting-the-base_ref-branch
feat: add support for setting the base_ref branch of a tag
This commit is contained in:
commit
fe2afbf4a7
12
.github/workflows/test.yml
vendored
12
.github/workflows/test.yml
vendored
@ -22,9 +22,6 @@ jobs:
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3.0.2
|
||||
- name: Show github context
|
||||
run: |
|
||||
echo '${{ toJSON(github) }}'
|
||||
- name: Run test
|
||||
id: branch-name
|
||||
uses: ./
|
||||
@ -74,14 +71,9 @@ jobs:
|
||||
echo "Current branch unset: ${{ steps.branch-name.outputs.current_branch }}"
|
||||
exit 1
|
||||
- name: Test current_branch output for tag based push event.
|
||||
if: github.event_name == 'push' && steps.branch-name.outputs.is_tag == 'true' && !steps.branch-name.outputs.current_branch
|
||||
if: github.event_name == 'push' && steps.branch-name.outputs.is_tag == 'true' && !steps.branch-name.outputs.base_ref_branch
|
||||
run: |
|
||||
echo "Current branch unset: ${{ steps.branch-name.outputs.current_branch }}"
|
||||
exit 1
|
||||
- name: Test is_tag output for tag based push event.
|
||||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') == 'true'
|
||||
run: |
|
||||
echo "Current branch unset: ${{ steps.branch-name.outputs.current_branch }}"
|
||||
echo "Base ref unset: ${{ steps.branch-name.outputs.base_ref_branch }}"
|
||||
exit 1
|
||||
- name: Test tag output for tag based push event.
|
||||
if: github.event_name == 'push' && steps.branch-name.outputs.is_tag == 'true' && !steps.branch-name.outputs.tag
|
||||
|
10
action.yml
10
action.yml
@ -54,6 +54,11 @@ runs:
|
||||
REF_BRANCH=${REF_BRANCH/refs\/heads\//}
|
||||
|
||||
echo "::set-output name=ref_branch::$(eval printf "%s" "$REF_BRANCH")"
|
||||
else
|
||||
BASE_REF=$(printf "%q" "${{ github.event.base_ref }}")
|
||||
BASE_REF=${BASE_REF/refs\/heads\/${{ inputs.strip_tag_prefix }}/}
|
||||
|
||||
echo "::set-output name=base_ref_branch::$(eval printf "%s" "$BASE_REF")"
|
||||
fi
|
||||
shell: bash
|
||||
- id: current_branch
|
||||
@ -65,11 +70,6 @@ runs:
|
||||
else
|
||||
echo "::set-output name=current_branch::${{ steps.branch.outputs.ref_branch }}"
|
||||
fi
|
||||
else
|
||||
REF=$(printf "%q" "${{ github.ref }}")
|
||||
REF_BRANCH=${REF/refs\/tags\/${{ inputs.strip_tag_prefix }}/}
|
||||
|
||||
echo "::set-output name=current_branch::$(eval printf "%s" "$REF_BRANCH")"
|
||||
fi
|
||||
shell: bash
|
||||
- id: default
|
||||
|
Loading…
x
Reference in New Issue
Block a user