Adding an action to set workflow as success when no change is made in target paths (#2553)

* update

* Update build.yml

* Update build.yml

* test workflow

* add build_check

* update
This commit is contained in:
Xiaoyun Zhang 2024-05-01 15:44:27 -07:00 committed by GitHub
parent 5fdaf1a8c0
commit e3ccf228e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 31 additions and 2 deletions

View File

@ -31,7 +31,7 @@ jobs:
test:
- "test/**"
workflows:
- ".github/workflows/build.yml"
- ".github/workflows/**"
setup:
- "setup.py"
- name: autogen has changes
@ -109,3 +109,32 @@ jobs:
with:
file: ./coverage.xml
flags: unittests
build-check:
if: always()
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Get Date
shell: bash
run: |
echo "date=$(date +'%m/%d/%Y %H:%M:%S')" >> "$GITHUB_ENV"
- name: Run Type is ${{ github.event_name }}
if: ${{ github.event_name != 'schedule' && github.event_name != 'workflow_dispatch'}}
shell: bash
run: |
echo "run_type=${{ github.event_name }}" >> "$GITHUB_ENV"
- name: Fail workflow if build failed
id: check_build_failed
if: contains(join(needs.*.result, ','), 'failure')
uses: actions/github-script@v6
with:
script: core.setFailed('Build Failed!')
- name: Fail workflow if build cancelled
id: check_build_cancelled
if: contains(join(needs.*.result, ','), 'cancelled')
uses: actions/github-script@v6
with:
script: core.setFailed('Build Cancelled!')

View File

@ -67,7 +67,7 @@ jobs:
defaults:
run:
working-directory: dotnet
if: success() && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dotnet')
if: success() && (github.ref == 'refs/heads/main')
needs: build
steps:
- uses: actions/checkout@v4