From e3ccf228e23940f7e27c28ea71dc3167fd6cb6e1 Mon Sep 17 00:00:00 2001 From: Xiaoyun Zhang Date: Wed, 1 May 2024 15:44:27 -0700 Subject: [PATCH] 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 --- .github/workflows/build.yml | 31 +++++++++++++++++++++++++++++- .github/workflows/dotnet-build.yml | 2 +- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3ec01d7a0..d06999db3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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!') diff --git a/.github/workflows/dotnet-build.yml b/.github/workflows/dotnet-build.yml index 046a5b6d7..1735e71a8 100644 --- a/.github/workflows/dotnet-build.yml +++ b/.github/workflows/dotnet-build.yml @@ -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