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.

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

AWS Security LIVE!

Hosted by security experts, AWS Security LIVE! showcases AWS Partners tackling real-world security challenges. Join live and get your security questions answered.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️