From 348b1f68bbcb861c0f947e84c69cc78d602fbdb5 Mon Sep 17 00:00:00 2001 From: Dana Doherty Date: Tue, 22 Oct 2024 14:53:51 +0100 Subject: [PATCH] Add on-failure job to nightly workflow and test with the workflow-restarter-test --- .github/workflows/nightly.yml | 23 +++++++ .github/workflows/workflow-restarter-test.yml | 63 ------------------- 2 files changed, 23 insertions(+), 63 deletions(-) delete mode 100644 .github/workflows/workflow-restarter-test.yml diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index f07bc156..4c090b04 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -35,3 +35,26 @@ jobs: secrets: "inherit" with: ruby_version: ${{ matrix.ruby_version }} + + on-failure-workflow-restarter-proxy: + # (1) run this job after the "spec" job and... + needs: [spec, acceptance] + # (2) continue ONLY IF "spec" fails + if: always() && needs.spec.result == 'failure' || needs.acceptance.result == 'failure' + runs-on: ubuntu-latest + steps: + # (3) checkout this repository in order to "see" the following custom action + - name: Checkout repository + uses: actions/checkout@v4 + + # (4) "use" the custom action to retrigger the failed "spec job" above + # NOTE: pass the SOURCE_GITHUB_TOKEN to the custom action because (a) it must have + # this to trigger the reusable workflow that restarts the failed job; and + # (b) custom actions do not have access to the calling workflow's secrets + - name: Trigger reusable workflow + uses: "puppetlabs/cat-github-actions/.github/actions/workflow-restarter-proxy@main" + env: + SOURCE_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + repository: ${{ github.repository }} + run_id: ${{ github.run_id }} diff --git a/.github/workflows/workflow-restarter-test.yml b/.github/workflows/workflow-restarter-test.yml deleted file mode 100644 index 57406ffe..00000000 --- a/.github/workflows/workflow-restarter-test.yml +++ /dev/null @@ -1,63 +0,0 @@ -name: Workflow Restarter TEST - -on: - workflow_dispatch: - inputs: - fail: - description: > - For (spec, acceptance) jobs: - 'true' = (fail, succeed) and - 'false' = (succeed, fail) - required: true - default: 'true' -env: - SOURCE_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - -jobs: - spec: - runs-on: ubuntu-latest - steps: - - name: Check outcome - run: | - if [ "${{ github.event.inputs.fail }}" = "true" ]; then - echo "'spec' job succeeded" - exit 0 - else - echo "'spec' job failed" - exit 1 - fi - acceptance: - runs-on: ubuntu-latest - steps: - - name: Check outcome - run: | - if [ "${{ github.event.inputs.fail }}" = "true" ]; then - echo "'acceptance' job failed" - exit 1 - else - echo "'acceptance' job succeeded" - exit 0 - fi - - on-failure-workflow-restarter-proxy: - # (1) run this job after the "spec" job and... - needs: [spec, acceptance] - # (2) continue ONLY IF "spec" fails - if: always() && needs.spec.result == 'failure' || needs.acceptance.result == 'failure' - runs-on: ubuntu-latest - steps: - # (3) checkout this repository in order to "see" the following custom action - - name: Checkout repository - uses: actions/checkout@v4 - - # (4) "use" the custom action to retrigger the failed "spec job" above - # NOTE: pass the SOURCE_GITHUB_TOKEN to the custom action because (a) it must have - # this to trigger the reusable workflow that restarts the failed job; and - # (b) custom actions do not have access to the calling workflow's secrets - - name: Trigger reusable workflow - uses: "puppetlabs/cat-github-actions/.github/actions/workflow-restarter-proxy@main" - env: - SOURCE_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - repository: ${{ github.repository }} - run_id: ${{ github.run_id }} \ No newline at end of file