github-pr-checker
is a tool to help pull request to post comment and set assignees automatically.
This tool checks pull request event and gets changed files list through GitHub webhook. You can set regexp rules for the changed files and this tool post comments, assignees and reviwers from the rules.
At first, install golang. And gets dependensies.
$ make init
Then create config.yml and modify it for your own needs.
$ cp config.example.yml config.yml
$ vim config.yml
Create serverless.yml
$ cp serverless.example.yml serverless.yml
# see https://serverless.com/framework/docs/providers/aws/guide/serverless.yml/
$ vim serverless.yml
Then deploy it!
# $ AWS_ACCESS_KEY_ID=... AWS_SECRET_ACCESS_KEY=... make deploy
$ make deploy
...
Serverless: Stack update finished...
Service Information
service: serverless-github-pr-review
stage: dev
region: ap-northeast-1
stack: serverless-github-pr-review-dev
api keys:
None
endpoints:
POST - https://abcdefg.execute-api.ap-northeast-1.amazonaws.com/dev/func
functions:
func: serverless-github-pr-review-dev-func
layers:
None
Stack Outputs
FuncLambdaFunctionQualifiedArn: arn:aws:lambda:ap-northeast-1:...:function:serverless-github-pr-review-dev-func:1
ServiceEndpoint: https://abcdefg.execute-api.ap-northeast-1.amazonaws.com/dev
ServerlessDeploymentBucketName: serverless-github-pr-review-dev-serverlessdeploymentbuck-123456
On the above example, endpoint URL is https://abcdefg.execute-api.ap-northeast-1.amazonaws.com/dev
.
Set the URL to GitHub repository's webhook Payload URL.
# $ GITHUB_PR_API_TOKEN=... go run ./cmd/httpserver/main.go
$ GITHUB_PR_HTTP_PORT=3000 go run ./cmd/httpserver/main.go
If you debug in local machine, smee.io will be really helpful.
# console #1
$ GITHUB_PR_HTTP_PORT=3000 go run ./cmd/httpserver/main.go
# console #2
# $ npm install -g smee-client
$ smee -u https://smee.io/123456
Go to https://github.com/<owner>/<repo name>/settings/hooks/new
and set data.
Name | Data |
---|---|
Payload URL |
Set HTTP server's URL or Serverless Endpoint. |
Content type |
application/json |
Secret |
Keep blank. If you set it, then set webhook_secret in config.yml |
Which events would you like to trigger this webhook? |
Use Let me select individual events. and check Pull requests |
Active |
Check! |
Name | Description |
---|---|
GITHUB_PR_HTTP_PORT |
HTTP server's listen port. (default: 3000 ) |
GITHUB_PR_CONFIG_FILE |
Config setting yaml file. (default: config.yml ) |
GITHUB_PR_API_TOKEN |
GitHub's personal access token. |
GITHUB_PR_API_TOKEN_KMS |
GitHub's personal access token encrypted by AWS KMS. |