Created
November 18, 2021 17:50
-
-
Save andyfeller/7cf991f5f086ba1ccda5971fb590cf2f to your computer and use it in GitHub Desktop.
Using GitHub Action workflow to retrigger a workflow that failed
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: fail | |
on: | |
workflow_dispatch: | |
inputs: | |
fail: | |
description: whether to fail the workflow | |
type: boolean | |
default: false | |
jobs: | |
fail: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Intentional fail | |
if: ${{ github.event.inputs.fail == 'true' }} | |
run: | | |
bash -c 'exit 1' | |
- name: Success | |
run: | | |
echo 'Success!' |
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: retrigger-fail | |
on: | |
workflow_run: | |
workflows: ["fail"] | |
types: [completed] | |
jobs: | |
on-failure: | |
runs-on: ubuntu-latest | |
if: ${{ github.event.workflow_run.conclusion == 'failure' }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Retrigger workflow without fail condition | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_CLI_TOKEN }} | |
run: | | |
gh workflow run fail --ref ${{ github.ref_name }} --field fail=false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@andyfeller
that restriction is still unfortunately in place.
https://docs.github.com/en/enterprise-cloud@latest/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow
this limits actions from pushing a commit with generated files or automatic fixes 😢. github support linked me this gist as a possible workaround.