Skip to content

Commit

Permalink
CI: Filter ci actions by path (#2094)
Browse files Browse the repository at this point in the history
  • Loading branch information
shamoon committed Sep 30, 2023
1 parent e890e6c commit 2e6e1d0
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
28 changes: 26 additions & 2 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,32 @@ 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'
name: Docker Build & Push
needs: changes
if: needs.changes.outputs.src == 'true' && github.repository == 'benphelps/homepage'
runs-on: self-hosted
permissions:
contents: read
Expand All @@ -40,7 +64,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
Expand Down
21 changes: 19 additions & 2 deletions .github/workflows/docs-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 2e6e1d0

Please sign in to comment.