Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Ground Controller Lvl 1
Message 1 of 16

pull_request action does not run on merge

I upgraded to the new GitHub Actions released last week with the YAML syntax. My action -- which uses `on: pull_request` -- no longer seems to run when a Pull Request is merged. Previously, this would trigger a run with the payload's `.action` equal to `closed`, which is exactly what I want. After the upgrade, it just doesn't run.

 

Note that if I manually close the Pull Request without merging, the action fires as expected.

 

Is this By Design? Should I switch to using the branch `close` event type? That would be a bit unfortunate given that I'd now need to duplicate some workflow logic, but certainly seems like a workaround at the very lease.

 

Thanks. Full workflow below:

 

```

name: Pulumify
on: pull_request
jobs:
  updateLivePreview:
    name: Update Live Preview
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@master
         if: github.event.action != 'closed'
         with:
            ref: ${{ github.event.pull_request.head.ref }}
            fetch-depth: 1
      - uses: pulumi/actions-pulumify@master
         env:

    ...
```

15 Replies
Community Manager
Message 2 of 16

Re: pull_request action does not run on merge

In your sample workflow you have: `if: github.event.action != 'closed'`, in other words your workflow step will not run when the `action` is `closed`. When a pull request is merged, the event triggered has an `action`of `closed` and a `pull_request.merged` value of `true`, so your sample workflow would not match. This is the expected behavior.

 

If you want to match only pull requests that have been merged, you can use `if: github.event.pull_request.merged`.

 

I hope that helps!

Copilot Lvl 2
Message 3 of 16

Re: pull_request action does not run on merge

We have the same issue, albeit without setting a condition.

 

PRs that are created, synchronized, etc... trigger an Action. However, when a PR is closed, the Action is not triggered anymore.

 

It worked earlier with the HCL syntax, however since the new YAML workflows have been announced, the behaviour of our HCL workflow also changed so that closed PRs didn't trigger Actions anymore...

Copilot Lvl 3
Message 4 of 16

Re: pull_request action does not run on merge

Same here. Our workflow has no conditions, yet is still not triggering on 'pull_request' 'closed'.

Here's an example pull request that was closed:
https://github.com/WordPress/gutenberg/pull/17157

The checks tab still shows the check from when the pull request was opened. There's some logging in the 'pull-request-automation' action that shows this is the case:
https://github.com/WordPress/gutenberg/pull/17157/checks?check_run_id=201154358

In the repo's actions tab, the list of actions is only showing jobs where 'user created a pull request' even when that definitely wasn't the case:
https://github.com/WordPress/gutenberg/actions

Copilot Lvl 2
Message 5 of 16

Re: pull_request action does not run on merge

I've also noticed that things like pull_request edited or labeled does not trigger the workflow either.

Ground Controller Lvl 1
Message 6 of 16

Re: pull_request action does not run on merge

Getting this fixed would be super useful for the workflow we have in mind (label a PR, auto merge it).

 

amq
Ground Controller Lvl 1
Message 7 of 16

Re: pull_request action does not run on merge

Same here. The webhook I'm looking for (without the irrelevant info):

 

headers:
X-GitHub-Event: pull_request

payload:
{
  "action": "closed",
  "pull_request": {
    "merged": true
  }
}

 

My workflow:

name: CI

on: [pull_request]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - name: Pull request merged
      if: github.action == 'closed' && github.pull_request.merged == 'true'
      run: echo merged

And it simply does not get triggered at all, even if I would remove the if condition.

 

Use case: purge the pull request deployment.

Ground Controller Lvl 2
Message 8 of 16

Re: pull_request action does not run on merge

@amq just complementing, the other answers... your "if" condition needs "event" object, it could be:

 

name: CI

on:
pull_request:
types: [closed] jobs: build: runs-on: ubuntu-latest steps: - name: Pull request merged if: github.event.pull_request.merged == true run: echo merged

 

 

GitHub Staff
Message 9 of 16

Re: pull_request action does not run on merge

Hi @joeduffy! I am on the product team for GitHub Actions.

 

You're seeing this behavior because the default activity triggers for pull request are `opened, synchronize, reopened`. In order to fine grain control which PR events you want to trigger your workflow, definitely check out Triggering workflows for PR events and scroll down to the full event list.

For example if you want to trigger your workflow on PR close, you will need to use the following YAML

 

on:
  pull_request:
    types: [closed]
Copilot Lvl 3
Message 10 of 16

Re: pull_request action does not run on merge

I've been eagerly waiting for this feature to be implemented the last 3 weeks or so, thanks a lot! Now we can finally switch to the new action model! Thanks a lot! 👍