From 580b4b17bc57c4a8b2cab9889f93f629a1d419e9 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Mon, 15 May 2023 13:36:15 -0600 Subject: [PATCH 1/9] fix: bug retrieving the current branch name on pull request review event Closes: #234 --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index a6e44e2e..dad87372 100644 --- a/action.yml +++ b/action.yml @@ -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 From cebd56c9601a686fe1e08b2a9e5612564bf6275c Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Mon, 15 May 2023 13:37:34 -0600 Subject: [PATCH 2/9] Update test.yml --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 17942a1e..d6d50b5b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,6 +6,7 @@ on: - '*' branches: - main + pull_request_review: pull_request_target: pull_request: branches: From 19dc24d3747e6b60dddb25006a61c264020c8173 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Mon, 15 May 2023 14:16:44 -0600 Subject: [PATCH 3/9] Update action.yml --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index dad87372..a521e48a 100644 --- a/action.yml +++ b/action.yml @@ -75,9 +75,9 @@ runs: if [[ "${{ github.ref }}" != "refs/tags/"* ]]; 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 }}" + echo "::set-output name=current_branch::${{ github.event.pull_request.head.ref }}" else - echo "current_branch=${{ steps.branch.outputs.head_ref_branch }}" >> "$GITHUB_OUTPUT" + echo "current_branch=${{ github.event.pull_request.head.ref }}" >> "$GITHUB_OUTPUT" fi else if [[ -z "$GITHUB_OUTPUT" ]]; then From 4d9f7b7bce342cce6ada278b36fe6131ad11c819 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Mon, 15 May 2023 14:19:01 -0600 Subject: [PATCH 4/9] Update action.yml --- action.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index a521e48a..1aa54561 100644 --- a/action.yml +++ b/action.yml @@ -41,7 +41,7 @@ runs: # "Set branch names..." if [[ "${{ github.ref }}" != "refs/tags/"* ]]; then BASE_REF=$(printf "%q" "${{ 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 }}") BASE_REF=${BASE_REF/refs\/heads\//} @@ -75,9 +75,9 @@ runs: if [[ "${{ github.ref }}" != "refs/tags/"* ]]; then if [[ ${{ github.event_name }} == *"pull_request"* ]]; then if [[ -z "$GITHUB_OUTPUT" ]]; then - echo "::set-output name=current_branch::${{ github.event.pull_request.head.ref }}" + echo "::set-output name=current_branch::${{ steps.branch.outputs.head_ref }}" else - echo "current_branch=${{ github.event.pull_request.head.ref }}" >> "$GITHUB_OUTPUT" + echo "current_branch=${{ steps.branch.outputs.head_ref }}" >> "$GITHUB_OUTPUT" fi else if [[ -z "$GITHUB_OUTPUT" ]]; then From 41584fbfb48555a67051fc98ede206552371afff Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Mon, 15 May 2023 14:19:36 -0600 Subject: [PATCH 5/9] Update action.yml --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 1aa54561..b8f20965 100644 --- a/action.yml +++ b/action.yml @@ -75,9 +75,9 @@ runs: if [[ "${{ github.ref }}" != "refs/tags/"* ]]; then if [[ ${{ github.event_name }} == *"pull_request"* ]]; then if [[ -z "$GITHUB_OUTPUT" ]]; then - echo "::set-output name=current_branch::${{ steps.branch.outputs.head_ref }}" + echo "::set-output name=current_branch::${{ steps.branch.outputs.head_ref_branch }}" else - echo "current_branch=${{ steps.branch.outputs.head_ref }}" >> "$GITHUB_OUTPUT" + echo "current_branch=${{ steps.branch.outputs.head_ref_branch }}" >> "$GITHUB_OUTPUT" fi else if [[ -z "$GITHUB_OUTPUT" ]]; then From 76ea840a9e6738b7b098030e31d0727bc7a6194c Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Mon, 15 May 2023 14:24:43 -0600 Subject: [PATCH 6/9] Update test.yml --- .github/workflows/test.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d6d50b5b..4702f3f0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,7 +6,6 @@ on: - '*' branches: - main - pull_request_review: pull_request_target: pull_request: branches: @@ -42,22 +41,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 @@ -67,7 +66,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 From b6b5c6fc354c111bfe2d782f55abb3a46f09d079 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Mon, 15 May 2023 14:28:13 -0600 Subject: [PATCH 7/9] Update test.yml --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4702f3f0..b23631de 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -46,7 +46,7 @@ jobs: echo "Is default is invalid: ${{ steps.branch-name.outputs.is_default }}" exit 1 - name: Test is_default output for non pull request - if: contains(github.event_name, 'pull_request') && 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 From 7cd7680665ddb82bd544380d4a962daad72f2e92 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Mon, 15 May 2023 14:30:43 -0600 Subject: [PATCH 8/9] Update test.yml --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b23631de..605e0c35 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,6 +6,7 @@ on: - '*' branches: - main + pull_request_review: pull_request_target: pull_request: branches: From d6cfbc028a637623ad2c58d9f7c081297320fd8e Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Mon, 15 May 2023 14:32:27 -0600 Subject: [PATCH 9/9] Update action.yml --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index b8f20965..d533e701 100644 --- a/action.yml +++ b/action.yml @@ -40,7 +40,7 @@ runs: run: | # "Set branch names..." 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.event.pull_request.head.ref || github.head_ref }}") REF=$(printf "%q" "${{ github.ref }}")