LoginSignup
6
5

More than 5 years have passed since last update.

GitHub APIでPull Requestにコメントを付ける

Posted at

今度はコメントを付けてみたくなったのでやってみた。

前提

GitHubで「Personal access tokens」からrepoに対して操作可能なTokenを取得しておく。

GitHub APIリファレンス

Create a comment

実行してみる

Pull Requestにコメントを付ける

curl -X POST -H 'Content-Type:application/json' -d "{\"body\":\"GitHub APIからコメント投稿\"}" https://api.github.com/repos/kz800/hoge/issues/1/comments?access_token=xxxxx

コメント投稿に成功するとAPIリファレンスにある形式でレスポンスがあります。

結果を確認してみる

コメントを付けたPRを開きます。
https://github.com/kz800/hoge/pull/1

ばっちりコメントが付いているので投稿成功です。
image

このAPIはPRに対してコメントを付けるAPIでしたが、
特定のファイルの特定の行にインラインコメントを付けるAPIもあるようなので、
そのうち試したら追記することにしよう。

6
5
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
6
5