Filter ci actions by path

This commit is contained in:
shamoon 2023-09-30 10:40:51 -07:00
parent e890e6c46c
commit 27542609af
2 changed files with 44 additions and 4 deletions

View File

@ -23,8 +23,31 @@ env:
jobs: 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: build:
if: github.repository == 'benphelps/homepage' needs: changes
if: needs.changes.outputs.src == 'true' && github.repository == 'benphelps/homepage'
runs-on: self-hosted runs-on: self-hosted
permissions: permissions:
contents: read contents: read
@ -40,7 +63,7 @@ jobs:
# Install the cosign tool except on PR # Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer # https://github.com/sigstore/cosign-installer
- name: Install cosign - name: Install cosign
if: github.event_name != 'pull_request' if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@main uses: sigstore/cosign-installer@main
with: with:
cosign-release: 'v1.13.1' # optional cosign-release: 'v1.13.1' # optional

View File

@ -11,9 +11,25 @@ permissions:
contents: write contents: write
jobs: 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: test:
needs: changes
name: Test Build 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 runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
@ -35,8 +51,9 @@ jobs:
- name: Test Docs Build - name: Test Docs Build
run: MKINSIDERS=true mkdocs build run: MKINSIDERS=true mkdocs build
deploy: deploy:
needs: changes
name: Build & Deploy 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 runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4