Bot to comment on GitHub pull requests.
- Create a bot account on GitHub.
- Generate a personal access token with the
public_reposcope from the bot account. - Make sure the following environment variables are available:
PORT: Port to run the serverGH_AUTH_TOKEN: Access token for GitHub.GH_REPO_OWNER: Organization or username on whose repos the bot can comment.GH_COMMENT_AUTHOR: Username of the bot.
- Run
yarnto install the dependencies. - Run
yarn startto start the server.
To comment on a pull request, send a POST request to the /comment endpoint with JSON data including pull_request and template properties:
curl \
-d '{"pull_request": "https://github.com/username/reponame/pull/123", "template": "It works!"}' \
-H "Content-Type: application/json" \
-X POST http://localhost:3024/commentThe JSON data can have the following properties
pull_request(required): Link to the pull request on which to comment.template(required): Comment template using Mustache, the data for the PR is passed to the template.test: An object with the shape{ type: "string", data: "Some string" }or{ type: "regex", data: "/^Some/" }to test against existing comments to determine if it should be a new comment or should be skipped.update: Boolean specifying whether to update the existing comment matching a provided test instead of skipping it.
Made with ❤️.