From 520e5aadb33aba2e2767d05ec7fc5bfef269e421 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 12 Feb 2021 16:30:56 -0500 Subject: [PATCH 1/4] Update action.yml --- action.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/action.yml b/action.yml index 335f5c4..cea5eb4 100644 --- a/action.yml +++ b/action.yml @@ -16,6 +16,9 @@ inputs: required: false outputs: + is_default: + value: ${{ steps.current_branch.outputs.is_default }} + description: 'Returns "true" if the current branch is the default else "false".' 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).' @@ -50,6 +53,13 @@ runs: echo "::set-output name=current_branch::${{ steps.branch.outputs.ref_branch }}" fi shell: bash + - id: is_default + run: | + if [[ "${{ steps.current_branch.outputs.current_branch }}" == "${{ steps.current_branch.outputs.base_ref_branch }}" ]]; then + echo "::set-output name=is_default::true" + else + echo "::set-output name=is_default::false" + fi branding: icon: git-branch From ff26f78e3b6b23a90013f714727f9505f3bbb589 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 12 Feb 2021 16:33:03 -0500 Subject: [PATCH 2/4] Update action.yml --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index cea5eb4..ec3eb82 100644 --- a/action.yml +++ b/action.yml @@ -17,7 +17,7 @@ inputs: outputs: is_default: - value: ${{ steps.current_branch.outputs.is_default }} + value: ${{ steps.default.outputs.is_default }} description: 'Returns "true" if the current branch is the default else "false".' current_branch: value: ${{ steps.current_branch.outputs.current_branch }} @@ -53,7 +53,7 @@ runs: echo "::set-output name=current_branch::${{ steps.branch.outputs.ref_branch }}" fi shell: bash - - id: is_default + - id: default run: | if [[ "${{ steps.current_branch.outputs.current_branch }}" == "${{ steps.current_branch.outputs.base_ref_branch }}" ]]; then echo "::set-output name=is_default::true" From 0ec4c0c2f917c9b3b32c3bd30b75fba1df514dec Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Fri, 12 Feb 2021 16:34:07 -0500 Subject: [PATCH 3/4] Update action.yml --- action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/action.yml b/action.yml index ec3eb82..388a455 100644 --- a/action.yml +++ b/action.yml @@ -60,6 +60,7 @@ runs: else echo "::set-output name=is_default::false" fi + shell: bash branding: icon: git-branch From 0619e2257d6a7419b8089a809722ee880e5f308d Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 13 Feb 2021 05:39:40 -0500 Subject: [PATCH 4/4] Update test.yml --- .github/workflows/test.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4cb5c10..b32ac99 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,6 +24,17 @@ jobs: echo "Base Ref: ${{ steps.branch-name.outputs.base_ref_branch }}" echo "Head Ref: ${{ steps.branch-name.outputs.head_ref_branch }}" echo "Ref: ${{ steps.branch-name.outputs.ref_branch }}" + echo "Is Default: ${{ steps.branch-name.outputs.is_default }}" + - name: Check is_default for pull request + if: github.event_name == 'pull_request' && steps.branch-name.outputs.is_default != 'false' + run: | + echo "Is default is invalid: ${{ steps.branch-name.outputs.is_default }}" + exit 1 + - name: Check is_default for non pull request + if: github.event_name != 'pull_request' && 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 output if: github.event_name == 'pull_request' && !steps.branch-name.outputs.base_ref_branch run: |