mirror of
https://github.com/tj-actions/branch-names.git
synced 2024-11-27 11:13:50 +08:00
fix: bug retrieving the current branch name on pull request review event (#235)
This commit is contained in:
parent
d53a4f56f3
commit
604fda4f42
11
.github/workflows/test.yml
vendored
11
.github/workflows/test.yml
vendored
@ -6,6 +6,7 @@ on:
|
|||||||
- '*'
|
- '*'
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
pull_request_review:
|
||||||
pull_request_target:
|
pull_request_target:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
@ -41,22 +42,22 @@ jobs:
|
|||||||
echo "Is Tag: ${{ steps.branch-name.outputs.is_tag }}"
|
echo "Is Tag: ${{ steps.branch-name.outputs.is_tag }}"
|
||||||
echo "Current tag: ${{ steps.branch-name.outputs.tag }}"
|
echo "Current tag: ${{ steps.branch-name.outputs.tag }}"
|
||||||
- name: Test is_default output for pull request
|
- name: Test is_default output for pull request
|
||||||
if: (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && steps.branch-name.outputs.is_tag == 'false' && steps.branch-name.outputs.is_default != 'false'
|
if: contains(github.event_name, 'pull_request') && steps.branch-name.outputs.is_tag == 'false' && steps.branch-name.outputs.is_default != 'false'
|
||||||
run: |
|
run: |
|
||||||
echo "Is default is invalid: ${{ steps.branch-name.outputs.is_default }}"
|
echo "Is default is invalid: ${{ steps.branch-name.outputs.is_default }}"
|
||||||
exit 1
|
exit 1
|
||||||
- name: Test is_default output for non pull request
|
- name: Test is_default output for non pull request
|
||||||
if: github.event_name != 'pull_request' && github.event_name != 'pull_request_target' && steps.branch-name.outputs.is_tag == 'false' && steps.branch-name.outputs.is_default != 'true'
|
if: "!contains(github.event_name, 'pull_request') && steps.branch-name.outputs.is_tag == 'false' && steps.branch-name.outputs.is_default != 'true'"
|
||||||
run: |
|
run: |
|
||||||
echo "Is default is invalid: ${{ steps.branch-name.outputs.is_default }}"
|
echo "Is default is invalid: ${{ steps.branch-name.outputs.is_default }}"
|
||||||
exit 1
|
exit 1
|
||||||
- name: Test base_ref_branch output
|
- name: Test base_ref_branch output
|
||||||
if: (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && steps.branch-name.outputs.is_tag == 'false' && !steps.branch-name.outputs.base_ref_branch
|
if: contains(github.event_name, 'pull_request') && steps.branch-name.outputs.is_tag == 'false' && !steps.branch-name.outputs.base_ref_branch
|
||||||
run: |
|
run: |
|
||||||
echo "Base ref unset: ${{ steps.branch-name.outputs.base_ref_branch }}"
|
echo "Base ref unset: ${{ steps.branch-name.outputs.base_ref_branch }}"
|
||||||
exit 1
|
exit 1
|
||||||
- name: Test head_ref output
|
- name: Test head_ref output
|
||||||
if: (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && steps.branch-name.outputs.is_tag == 'false' && !steps.branch-name.outputs.head_ref_branch
|
if: contains(github.event_name, 'pull_request') && steps.branch-name.outputs.is_tag == 'false' && !steps.branch-name.outputs.head_ref_branch
|
||||||
run: |
|
run: |
|
||||||
echo "Head ref unset: ${{ steps.branch-name.outputs.head_ref_branch }}"
|
echo "Head ref unset: ${{ steps.branch-name.outputs.head_ref_branch }}"
|
||||||
exit 1
|
exit 1
|
||||||
@ -66,7 +67,7 @@ jobs:
|
|||||||
echo "Ref unset: ${{ steps.branch-name.outputs.ref_branch }}"
|
echo "Ref unset: ${{ steps.branch-name.outputs.ref_branch }}"
|
||||||
exit 1
|
exit 1
|
||||||
- name: Test current_branch output for pull_request or pull_request_target event.
|
- name: Test current_branch output for pull_request or pull_request_target event.
|
||||||
if: (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && steps.branch-name.outputs.is_tag == 'false' && !steps.branch-name.outputs.current_branch
|
if: contains(github.event_name, 'pull_request') && steps.branch-name.outputs.is_tag == 'false' && !steps.branch-name.outputs.current_branch
|
||||||
run: |
|
run: |
|
||||||
echo "Current branch unset: ${{ steps.branch-name.outputs.current_branch }}"
|
echo "Current branch unset: ${{ steps.branch-name.outputs.current_branch }}"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -40,8 +40,8 @@ runs:
|
|||||||
run: |
|
run: |
|
||||||
# "Set branch names..."
|
# "Set branch names..."
|
||||||
if [[ "${{ github.ref }}" != "refs/tags/"* ]]; then
|
if [[ "${{ github.ref }}" != "refs/tags/"* ]]; then
|
||||||
BASE_REF=$(printf "%q" "${{ github.base_ref }}")
|
BASE_REF=$(printf "%q" "${{ github.event.pull_request.base.ref || github.base_ref }}")
|
||||||
HEAD_REF=$(printf "%q" "${{ github.head_ref }}")
|
HEAD_REF=$(printf "%q" "${{ github.event.pull_request.head.ref || github.head_ref }}")
|
||||||
REF=$(printf "%q" "${{ github.ref }}")
|
REF=$(printf "%q" "${{ github.ref }}")
|
||||||
|
|
||||||
BASE_REF=${BASE_REF/refs\/heads\//}
|
BASE_REF=${BASE_REF/refs\/heads\//}
|
||||||
@ -73,7 +73,7 @@ runs:
|
|||||||
run: |
|
run: |
|
||||||
# "Set the current branch name..."
|
# "Set the current branch name..."
|
||||||
if [[ "${{ github.ref }}" != "refs/tags/"* ]]; then
|
if [[ "${{ github.ref }}" != "refs/tags/"* ]]; then
|
||||||
if [[ ${{ github.event_name }} == 'pull_request' || ${{ github.event_name }} == 'pull_request_target' ]]; then
|
if [[ ${{ github.event_name }} == *"pull_request"* ]]; then
|
||||||
if [[ -z "$GITHUB_OUTPUT" ]]; then
|
if [[ -z "$GITHUB_OUTPUT" ]]; then
|
||||||
echo "::set-output name=current_branch::${{ steps.branch.outputs.head_ref_branch }}"
|
echo "::set-output name=current_branch::${{ steps.branch.outputs.head_ref_branch }}"
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user