From 2105bdc90567bf309b07efefc03d2d3bf1ead66f Mon Sep 17 00:00:00 2001 From: Alex Towle Date: Wed, 3 Apr 2024 20:47:07 -0500 Subject: [PATCH] Fixed the check-diff flow in the case of `push` events --- .github/workflows/check_diff.yaml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check_diff.yaml b/.github/workflows/check_diff.yaml index 662fee9ec..e5c8be8b2 100644 --- a/.github/workflows/check_diff.yaml +++ b/.github/workflows/check_diff.yaml @@ -16,7 +16,7 @@ jobs: check: runs-on: ubuntu-latest outputs: - changed: ${{ steps.check.outputs.changed }} + changed: ${{ steps.check-pr.outputs.changed || steps.check-push.outputs.changed }} steps: - uses: actions/checkout@v3 with: @@ -25,8 +25,9 @@ jobs: submodules: recursive token: ${{ secrets.GITHUB_TOKEN }} - - name: Check for changes - id: check + - name: Check for changes (Pull Request) + if: github.event_name == 'pull_request' + id: check-pr run: | FILES_CHANGED=$(git diff --name-only ${{ github.event.pull_request.base.sha }} HEAD) if echo "$FILES_CHANGED" | grep -m 1 "${{ inputs.pattern }}"; then @@ -34,3 +35,14 @@ jobs: else echo "changed=false" >> $GITHUB_OUTPUT fi + + - name: Check for changes (Push) + if: github.event_name == 'push' + id: check-push + run: | + FILES_CHANGED=$(git diff --name-only HEAD^ HEAD) + if echo "$FILES_CHANGED" | grep -m 1 "${{ inputs.pattern }}"; then + echo "changed=true" >> $GITHUB_OUTPUT + else + echo "changed=false" >> $GITHUB_OUTPUT + fi