Skip to content

Commit

Permalink
use conditional check to replace path filter in build and dotnet-ci w…
Browse files Browse the repository at this point in the history
…orkflow (microsoft#2546)

* use conditional check

* update
  • Loading branch information
LittleLittleCloud committed Apr 30, 2024
1 parent a0fffc8 commit d7dda9b
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 7 deletions.
37 changes: 32 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ name: Build
on:
push:
branches: ["main"]
paths:
- "autogen/**"
- "test/**"
- ".github/workflows/build.yml"
- "setup.py"
pull_request:
branches: ["main"]
merge_group:
Expand All @@ -21,7 +16,39 @@ concurrency:
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
permissions: {}
jobs:
paths-filter:
runs-on: ubuntu-latest
outputs:
hasChanges: ${{ steps.filter.outputs.autogen == 'true' || steps.filter.outputs.test == 'true' || steps.filter.outputs.workflows == 'true' || steps.filter.outputs.setup == 'true' }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
autogen:
- "autogen/**"
test:
- "test/**"
workflows:
- ".github/workflows/build.yml"
setup:
- "setup.py"
- name: autogen has changes
run: echo "autogen has changes"
if: steps.filter.outputs.autogen == 'true'
- name: test has changes
run: echo "test has changes"
if: steps.filter.outputs.test == 'true'
- name: workflows has changes
run: echo "workflows has changes"
if: steps.filter.outputs.workflows == 'true'
- name: setup has changes
run: echo "setup has changes"
if: steps.filter.outputs.setup == 'true'
build:
needs: paths-filter
if: needs.paths-filter.outputs.hasChanges == 'true'
runs-on: ${{ matrix.os }}
env:
AUTOGEN_USE_DOCKER: ${{ matrix.os != 'ubuntu-latest' && 'False' }}
Expand Down
19 changes: 17 additions & 2 deletions .github/workflows/dotnet-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ on:
workflow_dispatch:
pull_request:
branches: [ "main" ]
paths:
- 'dotnet/**'
push:
branches: [ "main" ]

Expand All @@ -21,9 +19,26 @@ permissions:
packages: write

jobs:
paths-filter:
runs-on: ubuntu-latest
outputs:
hasChanges: ${{ steps.filter.outputs.dotnet == 'true'}}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
dotnet:
- "dotnet/**"
- name: dotnet has changes
run: echo "dotnet has changes"
if: steps.filter.outputs.dotnet == 'true'
build:
name: Dotnet Build
runs-on: ubuntu-latest
needs: paths-filter
if: needs.paths-filter.outputs.hasChanges == 'true'
defaults:
run:
working-directory: dotnet
Expand Down

0 comments on commit d7dda9b

Please sign in to comment.