1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

GitHub ActionsでPRマージ時にワークフローを起動させる方法

Posted at

はじめに

GitHub Actionsでワークフローを起動させる際、プルリクエストのマージに対応するイベントがなく、別の記述を追加する必要があるのでまとめます。

コード

結論としては、ワークフローファイルのonjobsがそれぞれ下記のような形になります。

on: 
  pull_request:
    types: 
      - closed

jobs:
  if_merged:
    if: github.event.pull_request.merged == true
    runs-on: ubuntu-latest
    steps:
    - run: |
        echo The PR was merged

重要なのは以下の2つです。

マージされた時にワークフローをトリガーするための記述です。

types: 
  - closed

trueでジョブを実行、falseでジョブをスキップします。

if: github.event.pull_request.merged == true

参考情報

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?