Tirgger on Pull request merge not working

I set the following


name: CI

   on: [push, pull\_request]

But it’s not triggered on PR merge.

That is correct. By default, a workflow only runs when a pull_request’s activity type is opened, synchronize, or reopened. If you want to run a workflow when a PR is closed (and merged), you have to specifically set the closed type in the trigger conditions:

on:
  pull_request:
    types: [closed]

Additionally, to only make a job run when a PR was actually merged and not just closed without being merged, add the an “if” condition to your job(s) that checks if the merged property of the event is true:

jobs:
  deploy:
    runs-on: ubuntu-latest
    if: github.event.pull_request.merged

    steps:
      - name: Do stuff here...
2 Likes

I tried it all and it not running when the PR is opened or closed.

Can it be that the issue here is that the PR is opened by automaticly and merged by another action?

See here: https://github.com/RedisLabs/redis/tree/unstable/.github/workflows

You can see that the first sync.yml is doing auto repo sync and the second ci.yml should be triggered on every PUSH/PR

Events that are raised by the actions bot will not trigger other actions workflows.  This is to prevent you from getting in to an endless loop of worklfow runs.  We are looking at options to relax this restriction but we don’t have any specifics yet.

4 Likes