DEV Community

Takahiro Fukushima
Takahiro Fukushima

Posted on

Why can't I set "merged" Pull Request trigger on GitHub Actions?

I recently used GitHub Actions the first time, then I felt strange.
I often used Bitbucket Pipeline, but I didn't feel strange.

Why?

To feel strange

I used GitHub Actions first time, so I ran it through various settings.

The first, I made .github/workflows directory, then I wrote easy code.

name: example
on:
  push:
    branches:
    - main
    - develop
Enter fullscreen mode Exit fullscreen mode

I push code to main branch or develop branch, Pipeline run.
It's ok, I set push prohibition to main branch or develop branch.

Next, I'd like to pipeline run after pull request is permitted.

name: example
on:
  pull_request:
    types:
      - closed
    branches:
      - main
      - develop
Enter fullscreen mode Exit fullscreen mode

Just a moment, this code is pipeline run by permission or rejection if pull request is closed.

Let's research...but I can't find it.

For example, I'd like to get "merged" value,

name: example
on:
  pull_request:
    types:
      - merged   <=== This
    branches:
      - main
      - develop
Enter fullscreen mode Exit fullscreen mode

But this value is nothing.
Oh,,,

Blow link, same question as mine.
https://github.com/orgs/community/discussions/26724

Why feel strange

When I used Bitbucket Pipeline, I don't care about it.
For example Bitbucket Pipeline code.

pipelines:
  branches:
    main:
      - step:
    develop
      - step:
Enter fullscreen mode Exit fullscreen mode

Pipeline run after main branch or develop branch merge.
So pull request is rejected, pipeline don't run.

  1. pull request close
  2. pipeline don't run

I don't feel strange order of thinking.

but,

  1. pull request close
  2. pipeline run <=== Why it run?

I have no choice, let's just accept it.

Countermeasure

This code is countermeasure.

if: github.event.pull_request.merged == true
Enter fullscreen mode Exit fullscreen mode

So pipeline run, then pipeline stop.
But history of pipeline remains,,,It's ok.

Finally

I learn behavioral differences at similar services.
I'd like you to teach me same situation, programming language, tech services etc...

Have a good day.

Top comments (0)