GitHub Action gets Cancelled on Pull Request Close

We’ve been working on our first Actions implementation. We’ve got a lot of CI and make a temporary environment for each PR we open. I was hoping to use Actions to automatically terminate the environment when the relevant PR is closed.

As far as I can see everything looks right, and the action runs fine on all PR events (like synchronize etc) - though it does seem to run many times (I’m not sure if that’s relevant but it’s usually 3 to 6 invokations for each event).

Anyway the real issue is that when I close the PR, which is the event I’m looking for, the action is cancelled before it can get very far. I can’t see what is cancelling it or why.

I could restructure the action to be based on commits to master but I was hoping to find out more about what’s going wrong and fix it properly if possible.

Here’s what I see in the actions tab:

The log is pretty useless:

### CANCELLED is PR closed 23:21:52Z

Pulling image:
latest: Pulling from github-actions-images/action-runner
169185f82c45: Already exists
2901b28a22a0: Pulling fs layer
50462e5791bf: Pulling fs layer
d8279d8e7a61: Pulling fs layer
0be043e997bd: Pulling fs layer
0be043e997bd: Waiting
2901b28a22a0: Verifying Checksum
2901b28a22a0: Download complete
50462e5791bf: Verifying Checksum
50462e5791bf: Download complete
d8279d8e7a61: Verifying Checksum
d8279d8e7a61: Download complete
2901b28a22a0: Pull complete
50462e5791bf: Pull complete
0be043e997bd: Verifying Checksum
0be043e997bd: Download complete
d8279d8e7a61: Pull complete
0be043e997bd: Pull complete
Digest: sha256:6e8da1b4ffb0d13a38d4cd889c639d5d64962de4c1f65412bbc3f99cb7d9d7b2
Status: Downloaded newer image for
d466c100eb9020ee88f669a5c30308692003d2bfd7ef540aed7ec927793dd2b4: Pulling from gct-12-v5ksj6wjeda3dcf5ysa1tmx/2e035e5fb8ad977ee790ec390dcc01678860173c8af763469ce9edd9953e17f2/0c0528c9cdfbbd04f6b09b464de94fce116e820f638af7674f4ac129bf3d799a
4db7b1c4654c: Pulling fs layer
3d6eb57539bf: Pulling fs layer
584d43a794e5: Pulling fs layer
9ad65b91ab1c: Pulling fs layer
7c94794820e1: Pulling fs layer
9ad65b91ab1c: Waiting
7c94794820e1: Waiting
584d43a794e5: Verifying Checksum
584d43a794e5: Download complete
3d6eb57539bf: Verifying Checksum
3d6eb57539bf: Download complete
4db7b1c4654c: Verifying Checksum
4db7b1c4654c: Download complete
9ad65b91ab1c: Verifying Checksum
9ad65b91ab1c: Download complete
7c94794820e1: Verifying Checksum
7c94794820e1: Download complete
4db7b1c4654c: Pull complete
3d6eb57539bf: Pull complete
584d43a794e5: Pull complete
9ad65b91ab1c: Pull complete
7c94794820e1: Pull complete
Digest: sha256:37292e4c2725cb1f130982c4ad78763f3833dd153ca261eede1d698ce917a3b7
Status: Downloaded newer image for
Step 1/14 : FROM debian:stable-slim
stable-slim: Pulling from library/debian
4db7b1c4654c: Already exists
Digest: sha256:eb2aadb29b5e42b6e1e5e84974762f5f32c5cf564c5031b4a286e46a7ed614e8
Status: Downloaded newer image for debian:stable-slim
 ---> 618d33468038
Step 2/14 : LABEL "name"="filter"
 ---> Using cache
 ---> 17b0eb1f3a3b
Step 3/14 : LABEL "maintainer"="GitHub Actions <>"

And finally here’s my workflow:

workflow "Terminate PR environment" {
  on = "pull_request"
  resolves = [
    "Terminate Environment"

action "is PR closed" {
  uses = "actions/bin/filter@ec328c7554cbb19d9277fc671cf01ec7c661cd9a"
  args = "action close"

action "Terminate Environment" {
  needs = ["is PR closed"]
  uses = "actions/aws/cli@efb074ae4510f2d12c7801e4461b65bf5e8317e6"
  args = "elasticbeanstalk terminate-environment --environment-name pr$(jq -r .number $GITHUB_EVENT_PATH)"
  env = {
    AWS_DEFAULT_REGION = "eu-west-2"

Any help appreciated.


I have the same problem. It works fine even after closing the PR, but when deleting a branch, a new PR event gets dispatched, causes an action to cancel and lastly the PR to show “failed” (even though it was merged with only successful checks).