From 27542609afd168cd61afb9c39b35ab75237bdb82 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sat, 30 Sep 2023 10:40:51 -0700 Subject: [PATCH] Filter ci actions by path --- .github/workflows/docker-publish.yml | 27 +++++++++++++++++++++++++-- .github/workflows/docs-publish.yml | 21 +++++++++++++++++++-- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 3a727e3a..77aa0d93 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -23,8 +23,31 @@ env: jobs: + changes: + runs-on: ubuntu-latest + # Required permissions + permissions: + pull-requests: read + # Set job outputs to values from filter step + outputs: + src: ${{ steps.filter.outputs.src }} + steps: + - uses: dorny/paths-filter@v2 + id: filter + with: + filters: | + src: + - 'src/**' + - 'Dockerfile' + - 'docker-entrypoint.sh' + - 'package.json' + - 'package-lock.json' + - 'pnpm-lock.yaml' + - 'tailwind.config.js' + - 'postcss.config.js' build: - if: github.repository == 'benphelps/homepage' + needs: changes + if: needs.changes.outputs.src == 'true' && github.repository == 'benphelps/homepage' runs-on: self-hosted permissions: contents: read @@ -40,7 +63,7 @@ jobs: # Install the cosign tool except on PR # https://github.com/sigstore/cosign-installer - name: Install cosign - if: github.event_name != 'pull_request' + if: github.event_name != 'pull_request' uses: sigstore/cosign-installer@main with: cosign-release: 'v1.13.1' # optional diff --git a/.github/workflows/docs-publish.yml b/.github/workflows/docs-publish.yml index b0159f88..44cf8af0 100644 --- a/.github/workflows/docs-publish.yml +++ b/.github/workflows/docs-publish.yml @@ -11,9 +11,25 @@ permissions: contents: write jobs: + changes: + runs-on: ubuntu-latest + # Required permissions + permissions: + pull-requests: read + # Set job outputs to values from filter step + outputs: + docs: ${{ steps.filter.outputs.docs }} + steps: + - uses: dorny/paths-filter@v2 + id: filter + with: + filters: | + docs: + - 'docs/**' test: + needs: changes name: Test Build - if: github.repository == 'benphelps/homepage' && github.event_name == 'pull_request' + if: needs.changes.outputs.docs == 'true' && github.repository == 'benphelps/homepage' && github.event_name == 'pull_request' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -35,8 +51,9 @@ jobs: - name: Test Docs Build run: MKINSIDERS=true mkdocs build deploy: + needs: changes name: Build & Deploy - if: github.repository == 'benphelps/homepage' && github.event_name != 'pull_request' + if: needs.changes.outputs.docs == 'true' && github.repository == 'benphelps/homepage' && github.event_name != 'pull_request' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4