• This repository has been archived on 21/Mar/2020
  • Stars
    star
    19
  • Rank 1,163,249 (Top 23 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 7 years ago
  • Updated about 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

πŸ€– A bot that improve pull request workflow on GitHub.

lambda-pr-notify-bot

CircleCI license

πŸ€– A bot that improve pull request workflow on GitHub.

Features

  • πŸ”ƒ Add automatically reviewers to pull request
  • πŸ”” Send a direct messages to Slack
    • When the pull request is opened
    • When the pull request is approved
    • When the pull request is added mention comment
  • πŸ“Œ Manege WIP pull request by using a label

Configuration

How to create oauth token for send messages to Slack

  1. Access to Your Apps
  2. Click the Create New App
  3. Input App Name and Development Slack Workspace
  4. Select Permissions in Add features and functionality
  5. Add chat:write:bot in Permission Scopes
  6. Create a token
  7. Copy OAuth Access Token

How to create oauth token for request GitHub API.

  1. Access to Personal access tokens
  2. Click the Generate new token
  3. Input description in Token description
  4. Add repo in Select scopes
  5. Create a token
  6. Copy OAuth Access Token

How to run the bot on AWS

$ git clone https://github.com/kentaro-m/lambda-pr-notify-bot.git
$ cd lambda-pr-notify-bot
$ npm install
$ npm run package

Installing packages and building code.

{
  "host": "", // Required if using GitHub Enterprise
  "pathPrefix": "", // Required if using GitHub Enterprise
  "repositories": [ // Repositories that allows bot actions
    "unleash-sample"
  ],
  "reviewers": [ // Pull request reviewers (GitHub username)
    "matsushita-kentaro"
  ],
  "approveComments": [ // Comment on approving pull request
    "+1",
    "LGTM"
  ],
  "numApprovers": 1, // Number of people required for pull request approval
  "users": [ // Association between Slack user name and Github user name for notifying Slack
    {
      "github": "matsushita-kentaro",
      "slack": "kentaro"
    },
    {
      "github": "kentaro-m",
      "slack": "kentaro"
    }
  ],
  "message": { // Message to notify to Slack
    "requestReview": "Please review this pull request.",
    "ableToMerge": "Able to merge this pull request.",
    "mentionComment": "Please check this review comment."
  },
  "labels": {
    "wip": {
      "name": "wip", // display label name
      "color": "efb85f" // label color
    }
  },
  "workInProgress": true, // Bot manages WIP pull request by using a wip label
  "assignReviewers": true, // Bot adds a assignees to the pull request
  "requestReview": true, // Bot adds a reviewers to the pull request
  "ableToMerge": true, // Notify Slack that pull requests can be merged
  "mentionComment": true // Notify mention comment to Slack
}

Add reviewers (GitHub username), repositories and Slack username to config/default.json. Also, if necessary change other setting items.

  • GITHUB_API_TOKEN A token for obtaining information on pull requests (scope: repo)
  • SLACK_API_TOKEN A token for sending messages to Slack (scope: chat:write:bot)
  • SECRET_TOKEN A token for securing webhook

Add environment variables as parameters. (or Add environment variables on the Lambda management console.)

$ aws cloudformation package \ 
    --template-file pr-notify-bot.yml \ 
    --s3-bucket <Your bucket name> \ 
    --output-template packaged.yml
$ aws cloudformation deploy \ 
    --template-file packaged.yml \ 
    --stack-name <Your stack name> \
    --parameter-overrides GitHubApiToken=<GitHubApiToken value> SlackApiToken=<SlackApiToken value> SecretToken=<SecretToken value> \
    --capabilities CAPABILITY_IAM

Upload the SAM template to S3 and deploy it.

How to set up webhook on GitHub

  • Go to your project (or organization) settings > Webhooks > Add webhook
  • Payload URL https://<API ID>.execute-api.<AWS Region>.amazonaws.com/<Stage Name>/webhook
  • Content type application/json
  • Secret any value
  • Events Pull request, Pull request review, Pull request review comment, Issue comment

Options: Execute a Lambda Function on VPC

Please use it when assigning a static IP to execute a Lambda Function. Also, if necessary, please specify security group and subnet as parameters (An array of literal strings that are separated by commas.).

  • SecurityGroupIds The list of Security Group IDs for the HTTPS Access.
  • PrivateSubnetIds The list of VPC Private Subnet IDs for running the Lambda Function.
$ aws cloudformation package \
    --template-file pr-notify-bot-on-vpc.yml \
    --s3-bucket <Your bucket name> \
    --output-template packaged.yml
$ aws cloudformation deploy \
    --template-file packaged.yml \
    --stack-name <Your stack name> \ 
    --parameter-overrides GitHubApiToken=<GitHubApiToken value> SlackApiToken=<SlackApiToken value> SecretToken=<SecretToken value> SecurityGroupIds=<SecurityGroupIds value> PrivateSubnetIds=<PrivateSubnetIds value> \
    --capabilities CAPABILITY_IAM

Usage

Add automatically reviewers to pull request

  1. Pull request is created
  2. Add automatically reviewers to the pull request
  3. Send a direct message to Slack

Manege WIP pull request by using a label

  1. Create a pull request by including WIP in the title
  2. Add automatically wip label to the pull request
  3. Remove wip label, when the pull request is ready for review
  4. Add automatically reviewers to the pull request

Send a direct messages to Slack

  • When the pull request is opened
  • When the pull request is added mention comment
  • When the pull request is approved

Architecture

License

MIT

More Repositories

1

auto-assign-action

An action which adds reviewers to the pull request when the pull request is opened.
TypeScript
245
star
2

auto-assign

πŸ€– A Probot app that adds reviewers to pull requests when pull requests are opened.
TypeScript
234
star
3

md2confl

πŸ›  md2confl is a CLI tool to convert the markdown text to confluence wiki format.
Go
77
star
4

task-completed-checker-action

β˜‘οΈ A GitHub action that checks if all tasks are completed in the pull requests.
TypeScript
59
star
5

catchy-image

🎨 A Node.js module for dynamically generating social cards (open graph images).
JavaScript
46
star
6

blackfriday-confluence

πŸ›  Blackfriday-Confluence is confluence wiki renderer for the Blackfriday v2 markdown processor.
Go
21
star
7

add-an-issue-reference-action

:octocat: A GitHub Action for adding a related issue reference to a pull request.
TypeScript
18
star
8

gh-lspr

gh-lspr is GitHub CLI extension to help you to check pull requests to which you need to respond.
Shell
18
star
9

portfolio

😸 A my portfolio site that fetch data and display from various services such as GitHub, Qiita, SpeakerDeck.
CSS
12
star
10

portfolio-gatsby

😎 kentarom's portfolio site
SCSS
9
star
11

coverage-markers

πŸ“¦ Atom package to display JavaScript test coverage on gutter of editor.
JavaScript
6
star
12

issue-creator

πŸš„ A Slack slash command for creating quickly a new issue on GitHub.
JavaScript
6
star
13

task-complete-checker

βœ… A Probot app that checks if all tasks are completed in the pull requests.
JavaScript
5
star
14

honyaku-flag

🚩 A Slack app that translates a message when an emoji reaction added to the message.
TypeScript
5
star
15

mkissue

🎫 Create GitHub issues from importing CSV file.
TypeScript
4
star
16

qr-code-commenter-action

πŸ“· A GitHub Action that posts a QR code to a pull request comment.
TypeScript
4
star
17

japanese-tech-company-blog-updates

πŸ“Ί Deliver the latest tech news on Japanese technology companies.
Vue
4
star
18

pr-notify-bot

πŸ€– A slackbot that reminds reviewers to review their pull requests.
JavaScript
3
star
19

zenhub-time-tracker

⌚ Keep track of time to move an issue between pipelines and notify the time into Slack.
JavaScript
3
star
20

renovate-config

A config preset for Renovate used by @kentaro-m
3
star
21

waiting-for-review-labeler

⏰ An action for adding label to a pull request after it being opened or ready for review for more than certain hours.
TypeScript
2
star
22

resume

πŸ’» My resume
2
star
23

spider

πŸ‘· WIP A crawler for collecting tech news
Go
2
star
24

react-login-form-sample

πŸ”’ βš›οΈ A login form example with React Hooks
TypeScript
2
star
25

learn-something-new

πŸ’ͺ Knowledge is power.
TypeScript
2
star
26

homebrew-md2confl

Ruby
1
star
27

rust-learning

Rust
1
star
28

lighthouse-keeper

TypeScript
1
star
29

book-box

πŸ“šUpdate a pinned gist to contain the status of reading books from Google Books.
TypeScript
1
star
30

dotfiles

Vim Script
1
star
31

kentaro-m

1
star
32

blog

TypeScript
1
star
33

b64

πŸ› Base64 Encode/Decode Tool
JavaScript
1
star
34

shuf

🎲 Write a random permutation of the input lines to standard output.
TypeScript
1
star
35

tic-tac-toe

JavaScript
1
star
36

tic-tac-toe-with-typescript

Tic Tac Toe with TypeScript
TypeScript
1
star
37

waiting-for-review-labeler-demo

🎑 A sandbox to run the waiting-for-review-labeler
1
star
38

clean-architecture-todo-example

🚧 An implementation example of the Todo app using Clean Architecture.
TypeScript
1
star