Workflow Restarter TEST #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
- 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 }} |