From 66714ebcad0d42fd52074ed93d42b3755734cf19 Mon Sep 17 00:00:00 2001 From: Tonye Jack Date: Sat, 4 Dec 2021 07:00:44 -0500 Subject: [PATCH] Fixed error with test (#270) * Fixed error with test * Update action.yml --- .github/workflows/test.yml | 22 +++++++++++++--------- action.yml | 2 +- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 74ad784e..748cd2b0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -434,15 +434,6 @@ jobs: echo '${{ toJSON(steps.changed-files-custom-sha.outputs) }}' shell: bash - - name: Get branch name - id: branch-name - uses: tj-actions/branch-names@v5 - - uses: nrwl/last-successful-commit-action@v1 - id: last_successful_commit - with: - branch: ${{ steps.branch-name.outputs.base_ref_branch }} - workflow_id: 'test.yml' - github_token: ${{ secrets.GITHUB_TOKEN }} - name: Run changed-files with since_last_remote_commit set to true id: changed-files-since-last-remote-commit uses: ./ @@ -453,12 +444,25 @@ jobs: echo '${{ toJSON(steps.changed-files-since-last-remote-commit.outputs) }}' shell: bash + - name: Get branch name + id: branch-name + uses: tj-actions/branch-names@v5 + if: github.event_name == 'pull_request' + - uses: nrwl/last-successful-commit-action@v1 + id: last_successful_commit + if: github.event_name == 'pull_request' + with: + branch: ${{ steps.branch-name.outputs.base_ref_branch }} + workflow_id: 'test.yml' + github_token: ${{ secrets.GITHUB_TOKEN }} - name: Run changed-files with a custom base sha + if: github.event_name == 'pull_request' id: changed-files-custom-base-sha uses: ./ with: base_sha: ${{ steps.last_successful_commit.outputs.commit_hash }} - name: Show output + if: github.event_name == 'pull_request' run: | echo '${{ toJSON(steps.changed-files-custom-base-sha.outputs) }}' shell: diff --git a/action.yml b/action.yml index 556be076..7416b3a2 100644 --- a/action.yml +++ b/action.yml @@ -98,7 +98,7 @@ runs: # "Set base sha..." if [[ -n "${{ inputs.base_sha }}" ]]; then echo "::set-output name=base_sha::${{ inputs.base_sha }}" - elif [[ "${{ inputs.since_last_remote_commit }}" == "true" ]]; then + elif [[ "${{ inputs.since_last_remote_commit }}" == "true" && "${{ github.event.base_ref }}" != "null" ]]; then echo "::set-output name=base_sha::${{ github.event.before }}" fi id: base-sha