Cancel a workflow without considering it failed?

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 (chore type commits).

Example here

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?


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:

- name: set output
        run: echo ::set-output name=ifpublish::$(jq -r '.kind' <<< $result)
        id: check
      - name: skip did not publish commits
        if: steps.check.outputs.ifpublish != 'did_not_publish'
        run: |
          publish steps....

Hope it helps!

Thanks @weide-zhou that looks like it will solve the issue. I’ll give it a shot.

But, how do I put an if condition on a job based on the step output of a previous job in the workflow?

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?