Skip to content

Commit

Permalink
fix: bug retrieving the current branch name on pull request review ev…
Browse files Browse the repository at this point in the history
…ent (#235)
  • Loading branch information
jackton1 committed May 15, 2023
1 parent d53a4f5 commit 604fda4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- '*'
branches:
- main
pull_request_review:
pull_request_target:
pull_request:
branches:
Expand Down Expand Up @@ -41,22 +42,22 @@ jobs:
echo "Is Tag: ${{ steps.branch-name.outputs.is_tag }}"
echo "Current tag: ${{ steps.branch-name.outputs.tag }}"
- 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: |
echo "Is default is invalid: ${{ steps.branch-name.outputs.is_default }}"
exit 1
- 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: |
echo "Is default is invalid: ${{ steps.branch-name.outputs.is_default }}"
exit 1
- 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: |
echo "Base ref unset: ${{ steps.branch-name.outputs.base_ref_branch }}"
exit 1
- 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: |
echo "Head ref unset: ${{ steps.branch-name.outputs.head_ref_branch }}"
exit 1
Expand All @@ -66,7 +67,7 @@ jobs:
echo "Ref unset: ${{ steps.branch-name.outputs.ref_branch }}"
exit 1
- 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: |
echo "Current branch unset: ${{ steps.branch-name.outputs.current_branch }}"
exit 1
Expand Down
6 changes: 3 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ runs:
run: |
# "Set branch names..."
if [[ "${{ github.ref }}" != "refs/tags/"* ]]; then
BASE_REF=$(printf "%q" "${{ github.base_ref }}")
HEAD_REF=$(printf "%q" "${{ github.head_ref }}")
BASE_REF=$(printf "%q" "${{ github.event.pull_request.base.ref || github.base_ref }}")
HEAD_REF=$(printf "%q" "${{ github.event.pull_request.head.ref || github.head_ref }}")
REF=$(printf "%q" "${{ github.ref }}")
BASE_REF=${BASE_REF/refs\/heads\//}
Expand Down Expand Up @@ -73,7 +73,7 @@ runs:
run: |
# "Set the current branch name..."
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
echo "::set-output name=current_branch::${{ steps.branch.outputs.head_ref_branch }}"
else
Expand Down

0 comments on commit 604fda4

Please sign in to comment.