Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Post a comment on Github Pull Request via Command Line

Is there a way I can post a comment on a Github Pull Request via the command line? The ideas is that I want Jenkins to post comments on Pull Requests with a summary of the results of a script.

like image 253
Ebrahim Moshaya Avatar asked Jun 10 '26 09:06

Ebrahim Moshaya


2 Answers

This is absolutely possible with nothing more than curl.

curl \
  -X POST \
  -H "Accept: application/vnd.github.v3+json" \
  -H "Authorization: Bearer $GITHUB_TOKEN" \
  https://api.github.com/repos/octocat/hello-world/issues/42/comments \
  -d '{"body":"Hello Github!"}'

Read more about the API in use here https://docs.github.com/en/rest/reference/issues#create-an-issue-comment

NOTE: This assumes you have a Personal Access Token stored in an environment variable named GITHUB_TOKEN

like image 71
deedubs Avatar answered Jun 12 '26 11:06

deedubs


This is a little late, but this sounds like exactly what you are looking for:

gh pr comment 6 --body "Hi from GitHub CLI"

https://cli.github.com/manual/gh_pr_comment

Simply allows you to add comments to a pr from a given pr number.

like image 40
Porridge Avatar answered Jun 12 '26 11:06

Porridge



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!