Skip to content

Instantly share code, notes, and snippets.

@aserrallerios
Created November 7, 2023 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aserrallerios/cc2f186656250d00a2bd4dc6e58d740e to your computer and use it in GitHub Desktop.
Save aserrallerios/cc2f186656250d00a2bd4dc6e58d740e to your computer and use it in GitHub Desktop.
GHA error handling

GHA error handling info

  1. If a job fails, the whole workflow fails.
  2. If a step fails, the whole job fails.
  3. If a job is cancelled, the whole workflow is cancelled.
  4. If a step is cancelled, the whole job is cancelled.
  5. Every job/step can succeed/fail/cancel.
  6. The downstream jobs (with needs keyword) or following steps might decide to run, even when the previous jobs/steps have failed/cancelled, using the if keyword (but this won't change the status of the parent workflow/job):
    • always()
    • cancelled()
    • failure()
    • success() <- this is the default
  7. By default (if: success()) steps/jobs following a failure/cancel will be skipped.
  8. There's only one way to change the status of a job/step, this is using the continue-on-error keyword. This will "capture" failures and continue just as if it were a success.
  9. Reusable workflows cannot use continue-on-error from "outside", the reusable workflow should declare it from "inside".
  10. Whenever a workflow is cancelled, every step is cancelled at the same time. This will thus also cancel every running job.
  11. Steps that are running during cancel will be stopped unless they explicitly have the condition to run with cancel (if: always()/cancelled()).
  12. Steps will run for a maximum of 5 minutes after the workflow has been cancelled.
  13. It's impossible to revert a cancel (there's no continue-on-error equivalent).

Resources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment