cancel-workflow-action icon indicating copy to clipboard operation
cancel-workflow-action copied to clipboard

Fork-based setup seems to cancel itself and not the target workflows

Open agherzan opened this issue 3 years ago • 6 comments

I have a setup based on workflow_run. You can see it here. For whatever reason, when running, the job seems to cancel itself as opposed to the workflow that triggered it. My setup seems to be very simple so I'm wondering if I'm missing something obvious/fundamental.

agherzan avatar Feb 19 '22 22:02 agherzan

The workflow_id should be another workflow id (or workflow name), not itself.

See the README.md for example usage.

styfle avatar Feb 22 '22 13:02 styfle

@styfle I'm using a fork based setup so in my case the workflow_id is ${{ github.event.workflow.id }}. This is also in accordance with the Readme documentation. What am I missing?

agherzan avatar Feb 22 '22 14:02 agherzan

That feature was added in https://github.com/styfle/cancel-workflow-action/pull/55 and looks like its untested.

You could try using this example instead: https://github.com/vercel/next.js/blob/canary/.github/workflows/cancel.yml

styfle avatar Feb 22 '22 15:02 styfle

@styfle I guess we can consider it now tested - and failed :) I can try using pull_request_target. Is there a reason why not use pull_request?

agherzan avatar Feb 22 '22 16:02 agherzan

I think pull_request_target is necessary for forks if I remember correctly

styfle avatar Feb 22 '22 19:02 styfle

@styfle could you explain it a bit? I'm not sure what you mean because I am looking for a solution to cancelling workflows when PRs are landing both from forks and from internal branches.

agherzan avatar Feb 23 '22 16:02 agherzan

Looks like someone linked an issue with an example:

  • https://github.com/autowarefoundation/autoware.universe/pull/1741

styfle avatar Oct 03 '23 15:10 styfle