Cancel a workflow without considering it failed? #27174
-
How can a workflow be canceld but not considered a failure? The use-case is that we have a release system on every trunk commit but some types of commit should not result in a release ( Example here https://github.com/graphql-nexus/nexus-future/runs/503474761. We use the GitHub API to script this right now. But canceling a workflow marks the workflow as being in a failing state, which is untrue. How can we short-circuit a workflow without it being considered a failure? |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 1 reply
-
Hi @jasonkuhrt , It’s not supported, your workflow is cancelled from Rest API command, github will treat it as a failure one. Typically we will use ‘if’ expression to skip some jobs/steps while not cancelling the whole workflow. Code sample as below:
Hope it helps! |
Beta Was this translation helpful? Give feedback.
-
Thanks @weide-zhou that looks like it will solve the issue. I’ll give it a shot. |
Beta Was this translation helpful? Give feedback.
-
But, how do I put an if condition on a job based on the step output of a previous job in the workflow? |
Beta Was this translation helpful? Give feedback.
-
Having a similar issue here. Our use case is this: We have a parent repository, and whenever there’s a push on the parent repo, we have a set of child repos, which should be built incrementally. This incremental build is handled by a workflow. But when we have multiple commits (within a short time period) on the parent repo, there will be many incremental build workflow runs are triggered. Therefore, we wanted to cancel any already running workflow runs before running a new one. But this marks the cancelled workflow as a failed one, which isn’t the case here. Is there a workaround for this? |
Beta Was this translation helpful? Give feedback.
-
Hi! Is there a way to avoid to put |
Beta Was this translation helpful? Give feedback.
-
@weide-zhou I would agree with @cgr71ii ... this introduces a lot of code duplication and if you miss in a step refinement of the GHA workflow the If there is a |
Beta Was this translation helpful? Give feedback.
-
It is possible to cancel via the GH API, but you create a "cancel request", which means you need to hold/wait the action (sometimes up to 30s or more) to prevent further steps from progressing, while polling the API to see if it has canceled. There's a couple OSS actions which implement this behavior, but it's sub-optimal at best. Unfortunately there is no "reserved" exit code for processes to indicate signals (e.g. Someone would have to implement a Anyway. |
Beta Was this translation helpful? Give feedback.
-
Is there a workaround for cancelling a workflow without causing it to fail? Given that the workflow fails when it's cancelled via GitHub API, this will trigger all sorts of integrations to notify devs about a problem while there isn't one. Putting conditional We need an option to make cancellation non-failing and simply marked the workflow as |
Beta Was this translation helpful? Give feedback.
-
We have CI with concurrency group configured. It cancels all CI on a branch if a new commit pushed. |
Beta Was this translation helpful? Give feedback.
Hi @jasonkuhrt ,
It’s not supported, your workflow is cancelled from Rest API command, github will treat it as a failure one.
Typically we will use ‘if’ expression to skip some jobs/steps while not cancelling the whole workflow.
Code sample as below:
Hope it helps!