Under what circumstances is the github actions job context status property cancelled?

From job context

job.status | string | The current status of the job. Possible values are success, failure, or cancelled.

I have a test workflow with an action that cancels the workflow. With the job that cancels the workflow the status is success. Also from a job that needs that job the needs result is also reporting as success.

In the workflow log it says:

Run andymckay/cancel-action@0.2
Cancelled successfully.
##[debug]Node Action run completed with exit code 0
##[debug]Finishing: cancel workflow

So it successfully canceled the workflow and exits with code 0. Exit code 0 means that it was successful. It would need to quit with a non-zero exit code to make the job actually fail.

If you take a look at the code, then you will see that this cancel action only returns an exit code of 1 if it couldn’t cancel the workflow: cancel-action/cancel.js at 8debe723535f994e7f346efabc3837fd11549ba8 · andymckay/cancel-action · GitHub

If you want the demo-cancellation job to fail in any case, then you can do the following:

      - name: cancel workflow
        uses: andymckay/cancel-action@0.2
      - name: fail job
        run: exit 1