Giter VIP home page Giter VIP logo

backlog-notify's Introduction

Backlog Notify

GitHub Actions による CI check の結果 FOSSA によるライセンス分析の結果 Sonar Cloud による静的解析の結果 Deep Source による静的解析の結果 codecov によるテストカバレッジの結果

Notify commit messages to Backlog.com issue.

GitHub 上のプッシュとプルリクエストを Backlog 課題に連携する GitHub Action です。キーワードによる課題の状態変更も可能です。

個人が開発した Action です。ヌーラボ様へのお問い合わせはご遠慮ください。

機能

プッシュ

Backlog Notifyの動作をイメージした図。GitHub にプッシュすると Backlog にコミット情報のコメントがされる

コミットメッセージの中に課題番号 (例: PROJECT-123 ) がある場合は、その課題にコミットログに関するコメントを送信します。課題キーは先頭にある 1 つのみ認識します。

PROJECT-123 不具合修正

また、キーワードがある場合は、プッシュされたタイミングで課題ステータスを変更します。キーワードは末尾にある 1 つのみ認識します。

  • #fix #fixes #fixed のどれかで処理済み
  • #close #closes #closed のどれかで完了
PROJECT-123 不具合修正 #fix

※ 大量にプッシュするとそのまま投稿され、 Backlog に負荷がかかるのでご注意ください。

プルリクエスト

Backlog Notifyの動作をイメージした図。GitHub にプルリクエストを作成すると Backlog にプルリクエスト情報のコメントがされる

プルリクエストのタイトルの中に課題番号 (例: PROJECT-123 ) がある場合は、その課題にプルリクエストに関するコメントを送信します。課題キーは先頭にある 1 つのみ認識します。

PROJECT-123 不具合修正

また、キーワードがある場合は、マージされたタイミングで課題ステータスを変更します。キーワードは末尾にある 1 つのみ認識します。

  • #fix #fixes #fixed のどれかで処理済み
  • #close #closes #closed のどれかで完了
PROJECT-123 不具合修正 #fix

※ プルリクエストが Draft の状態である場合はコメント送信・ステータス操作をしません。
※ タイトルを変更した場合の通知は今のところ対応していません(対応予定)。Close → タイトルを変更 → Reopen を行うと通知されます。

設定方法

Backlog API キーの取得

  1. Backlog のプロジェクトに移動します。
  2. プロジェクト設定 → 参加ユーザー → 新しいユーザの追加はこちらから を選択します。
  3. クラシックプランの場合は 一般ユーザ 、新プランの場合は ゲスト を選択します。
  4. 登録します。
  5. 登録した BOT アカウントにログインします。
  6. 個人設定 → API → 登録 で API キーを発行します。

API キーを GitHub に登録

  1. GitHub のリポジトリページに移動します。
  2. Setting → Secrets → Add a new secret を選択します。
  3. Name は BACKLOG_API_KEY とし、 Value に API キーをそのまま貼り付けます。
  4. 登録します。

collaborator による workflow の実行を制限

プライベートリポジトリの場合は下記の操作を行う必要はありません。
パブリックリポジトリの場合は、collaborator からの workflow の実行を制限してください。

  1. Setting → Actions → Fork pull request workflows from outside collaborators を開きます。
  2. Require approval for all outside collaborators を選択します。

Workflow の作成

GitHub Actions workflow を作成します (例: .github/workflows/backlog-notify.yml )。

name: Backlog Notify

on:
  push:
  pull_request:
    types:
      - opened
      - reopened
      - ready_for_review
      - closed

jobs:
  notify:
    runs-on: ubuntu-latest
    steps:
      - name: Backlog Notify
        uses: bicstone/backlog-notify@v5
        with:
          project_key: PROJECT_KEY
          api_host: example.backlog.jp
          api_key: ${{ secrets.BACKLOG_API_KEY }}

高度な設定

Workflow syntax for GitHub Actions - GitHub Docs を参照に実行する条件を制御することができます。 また、コメントのフォーマットや、メッセージを解析する際の正規表現などをカスタマイズすることもできます。

name: Backlog Notify

on:
  push:
    branches:
      - main
  pull_request:
    types:
      - opened
      - reopened
      - ready_for_review
      - closed
    branches:
      - releases/**

jobs:
  notify:
    runs-on: ubuntu-latest
    steps:
      - name: Backlog Notify
        uses: bicstone/backlog-notify@v5
        with:
          # 必須設定 (The following are required settings)
          project_key: PROJECT_KEY
          api_host: example.backlog.jp
          api_key: ${{ secrets.BACKLOG_API_KEY }}

          # 任意設定 (The following are optional settings)
          fix_keywords: |-
            #fix
            #fixes
            #fixed
          close_keywords: |-
            #close
            #closes
            #closed
          push_comment_template: |-
            <%= commits[0].author.name %>さんが[<%= ref.name %>](<%= ref.url %>)にプッシュしました
            <% commits.forEach(commit=>{ %>
            + [<%= commit.comment %>](<%= commit.url %>) (<% print(commit.id.slice(0, 7)) %>)<% }); %>
          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 %>)
          commit_message_reg_template: "\
            ^\
            (<%= projectKey %>\\-\\d+)\\s?\
            (.*?)?\\s?\
            (<% print(fixKeywords.join('|')) %>|<% print(closeKeywords.join('|')) %>)?\
            $\
            "
          pr_title_reg_template: "\
            ^\
            (<%= projectKey %>\\-\\d+)\\s?\
            (.*?)?\\s?\
            (<% print(fixKeywords.join('|')) %>|<% print(closeKeywords.join('|')) %>)?\
            $\
            "
          fix_status_id: 3
          close_status_id: 4

設定一覧

設定名 説明
project_key Backlog プロジェクトキー (必須)
api_host Backlog のホスト (必須)
api_key Backlog API キー (必須)
fix_keywords 処理済みにするキーワード
close_keywords 完了にするキーワード
push_comment_template プッシュ時のコメント雛形
pr_opened_comment_template プルリクエストオープン時のコメント雛形
pr_reopened_comment_template プルリクエスト再オープン時のコメント雛形
pr_ready_for_review_comment_template プルリクエスト下書き解除時のコメント雛形
pr_closed_comment_template プルリクエストクローズ時のコメント雛形
pr_merged_comment_template プルリクエストマージ時のコメント雛形
commit_message_reg_template コミットメッセージ解析の正規表現雛形
pr_title_reg_template プルリクエストタイトル解析の正規表現雛形
fix_status_id 処理済みの 状態 ID
close_status_id 完了の 状態 ID

push_comment_template

プッシュ時のコメントの雛形を変更できます。
構文については lodash/template をご参照ください。

使用可能な変数
変数名
commits ParsedCommit[]
ref ParsedRef

ParsedCommit

変数名
id string
tree_id string
distinct boolean
message string
timestamp string
url string
author Committer
committer Committer
added string[]
modified string[]
removed string[]
issueKey string
comment string
keywords string
isFix boolean
isClose boolean

ParsedRef

変数名
name string
url string

Committer

変数名
name string
email string | null
date string | undefined
username string | undefined

pr_*_comment_template

プルリクエストイベントのコメントの雛形を変更できます。
構文については lodash/template をご参照ください。

使用可能な変数
変数名
pr PullRequest
action "opened" | "reopened" | "ready_for_review" | "closed" ※1
sender User
issueKey string
title string ※2
keywords string
isFix boolean
isClose boolean

※1 マージとクローズは共に "closed" となります。マージかどうか判別したい場合は pr.merged を参照ください。
※2 課題キーとキーワードを除いたタイトルです。加工前のタイトルは pr.title を参照ください。

PullRequest

Get a pull request - GitHub Docs の Response schema をご参照ください。

User

Get the authenticated user - GitHub Docs の Response schema をご参照ください。

commit_message_reg_template

コミットメッセージ解析の正規表現雛形を変更できます。
構文については lodash/template をご参照ください。

使用可能な変数
変数名
projectKey string
fixKeywords string[]
closeKeywords string[]

pr_title_reg_template

プルリクエストタイトル解析の正規表現雛形を変更できます。
構文については lodash/template をご参照ください。

使用可能な変数
変数名
projectKey string
fixKeywords string[]
closeKeywords string[]

よくある質問と回答

  • 何をプッシュしても実行に失敗し、ログに 401 エラーとある
    API キーが誤っている可能性があります。

  • プロジェクトキーと課題キーが正しいのに実行に失敗し、ログに 404 エラーとある
    該当 API キーのユーザーがプロジェクトに参加していない可能性があります。

貢献

コントリビューターの皆様に感謝いたします。

Thanks goes to these contributors.

Oishi Takanori
Oishi Takanori

🤔 💻 🚧 💬 📖 👀
takeshi.kondo
takeshi.kondo

🐛 💻
Kenta SUZUKI
Kenta SUZUKI

📖
mantaroh
mantaroh

🤔
Hyunjoon KIM
Hyunjoon KIM

🤔 💻
Shuya Honda
Shuya Honda

🤔

貢献はいつでも大歓迎です。事前に CONTRIBUTING.md をご確認ください。

Contributions of any kind welcome! Please read CONTRIBUTING.md.

ライセンス

MIT License

FOSSA Status

backlog-notify's People

Contributors

allcontributors[bot] avatar bicstone avatar deepsource-autofix[bot] avatar dependabot[bot] avatar hynjnk avatar mend-bolt-for-github[bot] avatar renovate-bot avatar renovate[bot] avatar stmon19 avatar suzuken avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

backlog-notify's Issues

Supports pull requests

  • Pull Request が生成されたり、承認された場合も通知できる
    • コメントのデフォルトを変更し、ブランチ名を表示することで、コメントからどのブランチにプッシュされたかがわかる
    • GitHub側からコメントでBacklogへのリンクを貼ることで、GitHub側からかんたんにBacklogへ移動できる

違うIDのチケットにコミットが割り当てられる

概要

EXAMPLE-123に紐付けたはずが、EXAMPLE-1にコミットが紐付いてしまいます。

コミットメッセージ

EXAMPLE-123 xxx #fix

紐付けられるチケット

EXAMPLE-1

チケットのメッセージ

23 xxx #fix

正規表現がおかしいみたいです。

Improve settings

  • コミットメッセージの正規表現、コメントのフォーマット、キーワードなど、すべてを設定から変更できる
    • GitHub Pages でテストできる
  • envではなく、withから設定ができる
  • 後方互換を維持する
    • 3項目(PROJECT_KEY, API_HOST, API_KEY)以外は設定しなくても1.1.0と同じ挙動をする
    • 3項目はenvで設定できる
  • (これで分岐が減るので) カバレッジを100%に近づける
  • テストのTODOを解消する

CVE-2020-28168 (Medium) detected in axios-0.20.0.tgz

CVE-2020-28168 - Medium Severity Vulnerability

Vulnerable Library - axios-0.20.0.tgz

Promise based HTTP client for the browser and node.js

Library home page: https://registry.npmjs.org/axios/-/axios-0.20.0.tgz

Path to dependency file: backlog-notify/package.json

Path to vulnerable library: backlog-notify/node_modules/axios/package.json

Dependency Hierarchy:

  • axios-0.20.0.tgz (Vulnerable Library)

Found in HEAD commit: ece4126a87a6179e4c1ec992dc6e3003635ae7d5

Found in base branch: master

Vulnerability Details

Axios NPM package 0.21.0 contains a Server-Side Request Forgery (SSRF) vulnerability where an attacker is able to bypass a proxy by providing a URL that responds with a redirect to a restricted host or IP address.

Publish Date: 2020-11-06

URL: CVE-2020-28168

CVSS 3 Score Details (5.9)

Base Score Metrics:

  • Exploitability Metrics:
    • Attack Vector: Network
    • Attack Complexity: High
    • Privileges Required: None
    • User Interaction: None
    • Scope: Unchanged
  • Impact Metrics:
    • Confidentiality Impact: High
    • Integrity Impact: None
    • Availability Impact: None

For more information on CVSS3 Scores, click here.


Step up your Open Source Security Game with WhiteSource here

refactor: default value

  • デフォルト値をコピペしてベタ書きしているので、定数化する
  • actions.yml のデフォルト値を削除する (js 側でデフォルト値をセットしているので)

Proposal: issueKeyをブランチ名から取得する機能の実装

@bicstone

Proposal: issueKeyをブランチ名から取得する機能の実装

私はブランチ名にBacklogのissueKeyを含めてPRを提出することがあります。(例えば feature/BACKLOG-1234 のような形式)
PRをオープン・クローズ・マージした際に、ブランチ名からissueKeyを抽出し、そのissueに対してコメントを投稿する機能がほしいです。

現在こちらのPR #67 でPRをオープン・クローズした際の通知機能は対応中であるように見受けられますが、以下のどちらかのアプローチでissueKeyの指定を柔軟に行えるように対応いただければ大変嬉しいです。
・正規表現を指定するだけでブランチ名からissueKeyを抽出してくれる
・前段のstepで別途ブランチ名からissueKeyの抽出は行うので、このactionのオプションとしてissueKeyを直接指定できる

以上、ご確認いただけますと幸いです。

Proposal:デプロイステータスの通知機能

Proposal :デプロイステータスの通知機能

Circle CI などのサービスで GitHub Issue へデプロイ結果を通知する機能があるが、同様に Backlog-notify へも通知したい。

モチベーション

backlog-notify で Nulab Backlgo 課題と連動することができるが、PR/コミットした際に CI/CD を設定していた場合に Backlog 上からビルドが成功したのかがわからない。

機能リクエスト

  • deploy_status のトリガーに対応
  • Backlog API の課題コメントを利用して deploy_status のコメントを投稿

参考

デプロイステータスの変更トリガー:https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#deployment_status

@bicstone

backlog-notify にこのようなコンセプトの機能追加は考えられているでしょうか?

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Awaiting Schedule

These updates are awaiting their schedule. Click on a checkbox to get an update now.

  • chore(deps): update devdependencies (@types/node, @typescript-eslint/eslint-plugin, @typescript-eslint/parser, husky)

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/test.yml
  • actions/checkout v4
  • actions/setup-node v4
  • codecov/codecov-action v4
nodenv
.node-version
  • node 20.15.1
npm
package.json
  • lodash.template 4.5.0
  • result-type-ts 2.1.3
  • @actions/core 1.10.1
  • @octokit/webhooks-examples 7.5.1
  • @octokit/webhooks-types 7.5.1
  • @types/jest 29.5.12
  • @types/lodash.template 4.5.3
  • @types/node 20.14.10
  • @typescript-eslint/eslint-plugin 7.16.0
  • @typescript-eslint/parser 7.16.0
  • @vercel/ncc 0.38.1
  • all-contributors-cli 6.26.1
  • eslint 8.57.0
  • eslint-config-prettier 9.1.0
  • eslint-plugin-import 2.29.1
  • eslint-plugin-n 17.9.0
  • eslint-plugin-promise 6.4.0
  • eslint-plugin-regexp 2.6.0
  • husky 9.0.11
  • jest 29.7.0
  • jest-mock 29.7.0
  • prettier 3.3.3
  • ts-jest 29.2.2
  • ts-node 10.9.2
  • typescript 5.5.3
  • node ^20.0.0
  • node 20.15.1

  • Check this box to trigger a request for Renovate to run again on this repository

System.ArgumentOutOfRangeExceptionが発生

概要

2023-06-23 深夜から backlog-notify にてエラーが発生するようになりました。

私は、以下の設定にて GitHub Actions 上で Backlog Notify をプロジェクトで利用しています。

name: Backlog Notify
on: push
jobs:
  backlog:
    runs-on: ubuntu-latest
    steps:
      - name: Backlog Notify
        uses: bicstone/backlog-notify@master
        env:
          PROJECT_KEY: XXXXXXXXXXXX
          API_HOST: xxxxxxxxxx.backlog.jp
          API_KEY: ${{ secrets.BACKLOG_API_KEY }}

昨夜から、以下のエラーが発生するようになりました。node のバージョンを上げたことが原因だと思われます。

using: node18

Download action repository 'bicstone/backlog-notify@master' (SHA:54aa39e85886abc7137e78cc63e6cbbbbf545044)
Error: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter ''using: node18' is not supported, use 'docker', 'node12' or 'node16' instead.')
   at GitHub.Runner.Worker.ActionManifestManager.ConvertRuns(IExecutionContext executionContext, TemplateContext templateContext, TemplateToken inputsToken, String fileRelativePath, MappingToken outputs)
   at GitHub.Runner.Worker.ActionManifestManager.Load(IExecutionContext executionContext, String manifestFile)
Error: Fail to load bicstone/backlog-notify/master/action.yml

プロジェクト側では、現在は master ではなく、v4.0.2 を指定することで問題なく動作しております。

uses: bicstone/[email protected]

確認よろしくお願いします。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.