3
1

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のPull RequestをBacklogに通知する「backlog-notify」

Last updated at Posted at 2025-12-06

対象とする読者

  • プロジェクト管理ツールとしてBacklogを使っている組織
  • ソースコード管理ツールとしてGitHubを使っている組織
  • 業務効率化に関心がある人

TL;DR

backlog-notifyを使うことで、Pull Requestの作成/クローズ/マージ 時に、Backlogの特定の課題へ通知することができます。
backlog-notifyはREADMEが充実しているので、使ってみたい方はREADMEをご覧ください。

ワークフロ-

私が実際の運用で使ったワークフローを記載します。

.github/workflows/backlog-notify.yaml
name: Backlog Notify

on:
  pull_request:
    types:
      - opened
      - reopened
      - ready_for_review
      - closed
    branches:
      - develop  # ブランチ戦略によって変更
      - hotfix/**  # ブランチ戦略によって変更

jobs:
  notify:
    runs-on: ubuntu-latest
    steps:
      - name: Backlog Notify
        uses: bicstone/backlog-notify@5a37d3b1ed2862a4c0b5d31113ac87fa80810049 # v6.1.0
        with:
          # 必須設定 (The following are required settings)
          project_key: ${{ vars.BACKLOG_PROJECT_KEY }}  # Repository variablesに設定
          api_host: ${{ vars.BACKLOG_API_HOST }}  # Organization variablesに設定
          api_key: ${{ secrets.BACKLOG_API_KEY }}  # Organization secretsに設定

          # 任意設定 (The following are optional settings)
          pr_opened_comment_template: |-
            <%= sender.login %>さんがプルリクエストを作成しました

            + [<%= title %>]( <%= pr.html_url %> ) (#<%= pr.number %>)
          pr_reopened_comment_template: |-
            <%= sender.login %>さんがプルリクエストを作成しました

            + [<%= title %>]( <%= pr.html_url %> ) (#<%= pr.number %>)
          pr_ready_for_review_comment_template: |-
            <%= sender.login %>さんがプルリクエストを作成しました

            + [<%= title %>]( <%= pr.html_url %> ) (#<%= pr.number %>)
          pr_closed_comment_template: |-
            <%= sender.login %>さんがプルリクエストをクローズしました

            + [<%= title %>]( <%= pr.html_url %> ) (#<%= pr.number %>)
          pr_merged_comment_template: |-
            <%= sender.login %>さんがプルリクエストをマージしました

            + [<%= title %>]( <%= pr.html_url %> ) (#<%= pr.number %>)
          pr_title_reg_template: "\
            ^\
            (<%= projectKey %>\\-\\d+)\\s?\
            (.*?)?\\s?\
            (<% print(fixKeywords.join('|')) %>|<% print(closeKeywords.join('|')) %>)?\
            $\
            "

ワークフローのトリガー

このワークフローでは、developブランチ、もしくはhotfix/*ブランチへのPull Requestにのみ、Backlogへ通知するようにしています。
ブランチ戦略によっては他のブランチ(mainreleases/**)を指定したり、ブランチ運用できていないプロジェクトに対してはpushをトリガーにしてもよいと思います。

(Backlogの通知数が多すぎると必要な情報が埋もれてしまう危険性があるので、まずは最小限の通知で運用するのがよいです)

SecretsやVariables

SecretsおよびVariablesについては、api_hostとapi_keyは組織で一意なことが多いためOrganizationで指定するのが、project_keyはプロジェクトごとに異なるためRepositoryで指定するのがよいです。

ワークフローの任意設定

ワークフローのデフォルト設定で、なおかつBacklogのテキスト整形が「Backlog記法」だと、Backlogに通知されるリンクがおかしくなります(半角括弧がURL末尾に加わってしまう)。
ですので、( <%= pr.html_url %> )のようにURLと半角括弧の間に半角スペースを入れています。

Backlogへの通知

Pull Requestの作成/クローズ/マージ 時に、このような通知がBacklogへ投稿されます。
backlog-notify.png

他メンバーへのメンションはされないので、「相手に気づいてもらう」という意味合いではなく、「Backlogに開発ステータスを記録する」という意味合いで利用するのがよいです。
レビュー依頼はPull RequestのReviewersを使いましょう。

おわりに

素敵なGitHub Actionsを作ってくださった制作者のbicstoneさんに感謝を。
ありがとうございます。

3
1
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
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?