I want to be able, based on a condition to cancel my current run of a workflow.
I tried to use this action like this
- name: cancel workflow if none of files we look for changes has not changed
if: steps.changed-files.outputs.any_changed != 'true'
uses: styfle/cancel-workflow-action@0.10.0
with:
workflow_id: ${{ github.workflow_id }}
access_token: ${{ github.token }}
but as it turns out from the logs:
Found token: yes
Found workflow_id: ["12345567"]
Found 3 runs total.
Found 0 runs to cancel.
it only cancels other concurrently running workflows.
Is there an easy way around this or should I resort to GH API?
edit: I have tried this from within the step that is supposed to cancel the rest of the workflow
gh api --method POST -H "Accept: application/vnd.github+json" https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/cancel
However it just returns a {} and the execution continues...