From 70747484a5355491a44ada997fab505939d20db8 Mon Sep 17 00:00:00 2001 From: Eric Swanson <64809312+ericswanson-dfinity@users.noreply.github.com> Date: Mon, 29 Jan 2024 06:10:18 -0800 Subject: [PATCH] fix: use dorny/paths-filter to include/skip a job with a required status. (#651) --- .github/workflows/motoko-counter-example.yaml | 28 +++++++++++++++---- .github/workflows/motoko-counter-skip.yaml | 20 ------------- 2 files changed, 23 insertions(+), 25 deletions(-) delete mode 100644 .github/workflows/motoko-counter-skip.yaml diff --git a/.github/workflows/motoko-counter-example.yaml b/.github/workflows/motoko-counter-example.yaml index 676825f57..562d7e181 100644 --- a/.github/workflows/motoko-counter-example.yaml +++ b/.github/workflows/motoko-counter-example.yaml @@ -4,16 +4,32 @@ on: branches: - master pull_request: - paths: - - motoko/counter/** - - .github/workflows/provision-darwin.sh - - .github/workflows/provision-linux.sh - - .github/workflows/motoko-counter-example.yaml concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: + # JOB to run change detection + changes: + runs-on: ubuntu-latest + permissions: + pull-requests: read + # Set job outputs to values from filter step + outputs: + sources: ${{ steps.filter.outputs.sources }} + steps: + # For pull requests it's not necessary to checkout the code + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + sources: + - motoko/counter/** + - .github/workflows/provision-darwin.sh + - .github/workflows/provision-linux.sh + - .github/workflows/motoko-counter-example.yaml motoko-counter-example-darwin: + needs: changes + if: ${{ needs.changes.outputs.sources == 'true' }} runs-on: macos-12 steps: - uses: actions/checkout@v1 @@ -26,6 +42,8 @@ jobs: make test popd motoko-counter-example-linux: + needs: changes + if: ${{ needs.changes.outputs.sources == 'true' }} runs-on: ubuntu-20.04 steps: - uses: actions/checkout@v1 diff --git a/.github/workflows/motoko-counter-skip.yaml b/.github/workflows/motoko-counter-skip.yaml deleted file mode 100644 index 225e19575..000000000 --- a/.github/workflows/motoko-counter-skip.yaml +++ /dev/null @@ -1,20 +0,0 @@ -name: motoko-counter -on: - pull_request: - paths-ignore: - - motoko/counter/** - - .github/workflows/provision-darwin.sh - - .github/workflows/provision-linux.sh - - .github/workflows/motoko-counter-example.yaml -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true -jobs: - motoko-counter-example-darwin: - runs-on: ubuntu-latest - steps: - - run: echo 'Not needed - relevant folder not touched' - motoko-counter-example-linux: - runs-on: ubuntu-latest - steps: - - run: echo 'Not needed - relevant folder not touched'