From e551a09baf7e0e158b4f2d7f6788ddcd6ee1d2dc Mon Sep 17 00:00:00 2001 From: Lukas Audzevicius Date: Wed, 29 Jan 2025 10:43:39 +0000 Subject: [PATCH] (MAINT) Implementing workflow restarter Following the addition of workflow restarter files to the repository, we are now making adjustments to ensure they work as expected. --- .github/workflows/nightly.yml | 20 ++++++ .github/workflows/workflow-restarter-test.yml | 63 ------------------- 2 files changed, 20 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 1b06c471..63a0ac78 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -14,3 +14,23 @@ jobs: needs: Spec uses: "puppetlabs/cat-github-actions/.github/workflows/module_acceptance.yml@main" secrets: "inherit" + + on-failure-workflow-restarter-proxy: + # (1) run this job after the "acceptance" job and... + needs: [Acceptance, Spec] + # (2) continue ONLY IF "acceptance" fails + if: always() && needs.Acceptance.result == 'failure' || needs.Spec.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 "acceptance job" above + - 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 cf3b1a17..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 (acceptance, unit) jobs: - 'true' = (fail, succeed) and - 'false' = (succeed, fail) - required: true - default: 'true' -env: - SOURCE_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - -jobs: - unit: - runs-on: ubuntu-latest - steps: - - name: Check outcome - run: | - if [ "${{ github.event.inputs.fail }}" = "true" ]; then - echo "'unit' job succeeded" - exit 0 - else - echo "'unit' 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 "acceptance" job and... - needs: [acceptance, unit] - # (2) continue ONLY IF "acceptance" fails - if: always() && needs.acceptance.result == 'failure' || needs.unit.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 "acceptance 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 }}