use conditional check to replace path filter in build and dotnet-ci workflow (#2546)

* use conditional check

* update
This commit is contained in:
Xiaoyun Zhang 2024-04-30 14:08:47 -07:00 committed by GitHub
parent a0fffc815b
commit d7dda9be09
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 49 additions and 7 deletions

View File

@ -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:
@ -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' }}

View File

@ -7,8 +7,6 @@ on:
workflow_dispatch:
pull_request:
branches: [ "main" ]
paths:
- 'dotnet/**'
push:
branches: [ "main" ]
@ -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