For my project, I have a pretty long github action that is triggered when a new pull request is created. These are the triggers I use:
on:
pull_request:
types: [opened, ready_for_review, labeled]
This action is defined as a "status check" requirement for my pull request, to make sure that the action is running fine before allowing someone to merge his PR.
But, my PRs also require to be up to date with develop before being allowed to merge anything.
So the scenario I encounter frequently is this:
- Create a new Pull Request
- The Github Action starts, and my PR's check status go to "in progress"
- I realise that my branch is not up to date with develop, so I update it.
- The PR's check status go to "Expected", since my current run was started on a previous version of the branch.
My issue with that scenario, is that, even though my github action run is now completely invalid/obsolete (because the content of the branch changed), the action itself is still running. I need to manually go to the actions tab and cancel this run.
Is there a way to automatically cancel this run, if the content of the branch or the PR changed ?