Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add path-filtering for PRs #36

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/czicompress_cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@ on:

permissions:
contents: read
pull-requests: read

jobs:
changes:
uses: ./.github/workflows/subproject-changes.yml

build-tests:
needs: changes
if: ${{ needs.changes.outputs.czicompress == 'true' }}
defaults:
run:
working-directory: ${{github.workspace}}/czicompress
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/czicompress_codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@ permissions:
actions: read
contents: read
security-events: write
pull-requests: read

jobs:
changes:
uses: ./.github/workflows/subproject-changes.yml

analyze:
needs: changes
if: ${{ needs.changes.outputs.czicompress == 'true' }}
name: Analyze CPP
defaults:
run:
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/czishrink_codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ on:
permissions: read-all

jobs:
changes:
uses: ./.github/workflows/subproject-changes.yml

analyze:
needs: changes
if: ${{ needs.changes.outputs.czishrink == 'true' }}
name: Analyze CziShrink
defaults:
run:
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/czishrink_dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ on:
workflow_dispatch: {}

jobs:
changes:
uses: ./.github/workflows/subproject-changes.yml

build:
needs: changes
if: ${{ needs.changes.outputs.czishrink == 'true' }}
defaults:
run:
working-directory: czishrink
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/subproject-changes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
# A reusable workflow that is used to detect whether code changes
# are relevant for czishrink and/or czicompress.
# See
# - https://github.com/dorny/paths-filter#examples
# - https://docs.github.com/en/actions/using-workflows/reusing-workflows
name: subproject-changes

# Required permissions
permissions:
pull-requests: read

on:
workflow_call:
outputs:
czishrink:
description: "'true' if the change affects czishrink or if github.event_name is not 'pull_request'; 'false' otherwise"
value: ${{ jobs.detect_changes.outputs.czishrink }}
czicompress:
description: "'true' if the change affects czicompress or if github.event_name is not 'pull_request'; 'false' otherwise"
value: ${{ jobs.detect_changes.outputs.czicompress }}

jobs:
# JOB to run change detection
detect_changes:
runs-on: ubuntu-latest
# Set job outputs to values from filter step for PRs, and true for other events.
outputs:
czishrink: ${{ steps.result.outputs.czishrink }}
czicompress: ${{ steps.result.outputs.czicompress }}
steps:
# For pull requests it's not necessary to checkout the code
- uses: dorny/paths-filter@v2
if: ${{ github.event_name == 'pull_request' }}
id: filter
with:
filters: |
czishrink:
- 'czishrink/**'
- '.github/**'
- '*.yml'
czicompress:
- '**czicompress**'
- '.github/**'
- '*.yml'
- id: result
run: |
echo "czishrink=${{ github.event_name != 'pull_request' || steps.filter.outputs.czishrink == 'true' }}"
echo "czicompress=${{ github.event_name != 'pull_request' || steps.filter.outputs.czicompress == 'true' }}"
echo "czishrink=${{ github.event_name != 'pull_request' || steps.filter.outputs.czishrink == 'true' }}" >> "$GITHUB_OUTPUT"
echo "czicompress=${{ github.event_name != 'pull_request' || steps.filter.outputs.czicompress == 'true' }}" >> "$GITHUB_OUTPUT"