吃谷维素有什么副作用| 什么叫性生活| 丛林之王是什么动物| 4月份有什么节日| 天顶星座是什么意思| 为什么总是拉肚子| 真丝乔其纱是什么面料| 什么是pid| 嵌甲去医院挂什么科| 头孢克肟和头孢拉定有什么区别| 胆囊息肉是什么意思| 脂肪肝不能吃什么| 低密度脂蛋白高有什么危害| 狐臭手术挂什么科| 什么情况会导致月经推迟不来| 新生的什么| 咖喱是什么| 人生得意须尽欢是什么意思| 沙土地适合种什么农作物| 玉是什么结构的字| 势力是什么意思| 老鸹是什么鸟| 大同有什么好吃的| 双向情感障碍吃什么药| 手指上长毛是什么原因| 了凡四训讲的是什么| 骨髓抑制是什么意思| 614是什么星座| pr过高是什么意思| tiamo是什么意思| 马眼是什么| 双子座女和什么座最配| 夏季养什么脏腑| 四肢抽搐口吐白沫是什么病| 渣男之首是什么星座| 4b橡皮和2b橡皮有什么区别| 牙龈化脓是什么原因| 朱的部首是什么| 纸醉金迷是什么意思| 上梁不正下梁歪是什么意思| 勃起不够硬吃什么药| 女人吃什么补气血| 小孩吃了就吐是什么原因| 孕妇吃什么水果比较好| 闷葫芦是什么意思| 为什么白天尿少晚上尿多| 尿道口有烧灼感为什么| 新生儿呛奶是什么原因引起的| 执行标准是什么意思| 爬行对身体有什么好处| 预防高原反应吃什么药| 豌豆有什么营养价值| ba是什么元素| al是什么| 胸闷心慌是什么病| hcg翻倍慢是什么原因| 趴在桌子上睡觉有什么坏处| 汤圆和元宵有什么区别| 妈妈的爸爸叫什么| 猪生肠是什么部位| 夏天什么花开| 诠释的意思是什么| 经常吃紧急避孕药有什么危害| uvb是什么意思| 五花肉和什么菜炒好吃| 梦到做饭是什么意思| 什么是偶数| 乳糖酶是什么东西| 血压高应该吃什么食物| 一什么气| 蠼螋吃什么| apc是什么意思| 传染性单核细胞增多症是什么病| 查脂肪肝做什么检查| 什么地赞叹| 跟腱炎贴什么膏药最好| 什么是阳光抑郁症| 一动就出汗吃什么药| 鸡枞是什么东西| 左克是什么药| 什么人吃天麻最好| 750金是什么金| 前列腺液是什么| 爱迪生发明什么| 阴唇肥大是什么原因| 女人吃什么补元气最快| 鸿字五行属什么| 罗汉果泡水喝有什么作用| 深圳车牌摇号需要什么条件| 尿酸挂什么科| 龟吃什么| 非文念什么| 泡脚不出汗是什么原因| 松花粉对肝有什么好处| 精神焦虑症有什么表现有哪些| 什么病才查凝血四项呢| 为什么尽量不打免疫球蛋白| kms是什么意思| 白鱼又叫什么鱼| 三亚在海南的什么位置| 四维彩超和大排畸有什么区别| 布病什么症状| 开除公职是什么意思| 喝什么饮料解酒| 眼前的苟且是什么意思| 京酱肉丝是什么菜系| 妇科炎症用什么药最好| 双重人格是什么意思| 狻猊是什么| 支原体培养阳性是什么意思| 早上起来眼皮肿是什么原因| 相夫教子是什么意思| 午夜梦回是什么意思| 膝盖有积液是什么症状| 不问世事什么意思| 惊鸿一面是什么意思| 大暑吃什么| 洛神花是什么花| 属鸡今年要注意什么| 睡觉总醒是什么原因| 血压高是什么症状| 喜用神是什么| 皮脂腺囊肿用什么药膏| 口腔医学专业学什么| 白细胞和血小板高是什么原因| 胃疼屁多是什么原因| 猪心炖什么好吃又营养| 高血压会引起什么病症| 耐药是什么意思| 女性膀胱炎是什么症状| 梦见蝎子是什么意思| 产后屁多是什么原因| 怀孕初期吃什么对胎儿发育好| 肺脓肿是什么病严重吗| 7.14号是什么节日| 暑湿是什么意思| 腹部b超挂什么科| 烫伤了抹什么| 女性感染hpv有什么症状| 吃槟榔有什么危害| 聊天是什么意思| 水肿是什么样子| 女生为什么喊你男神| 什么是功能性子宫出血| 中医科是看什么病的| 女生的小鸡鸡长什么样| 糖五行属什么| 九月七日是什么星座| 送女朋友什么礼物好| 什么飞什么舞| 腮腺炎看什么科室| 什么是遴选| 第一次怀孕有什么反应| 女的排卵期一般是什么时间| 肝硬化是什么引起的| 女人右手断掌代表什么| 胆固醇高不能吃什么水果| 什么花在什么时间开| 劳伦斯属于什么档次| 笔记本电脑什么牌子好| 不是经期有少量出血是什么原因| 脾肾阳虚吃什么药最好| 蜂蜜吃了有什么好处| 搬家有什么讲究| 纯牛奶可以做什么美食| 燕子进屋来有什么兆头| 柏字五行属什么| 太学是什么意思| 鼠入牛角是什么动物| 平舌音是什么意思| 画蛇添足告诉我们什么道理| 2006年是什么年| 什么药消肿最快最有效| 警察为什么叫蜀黍| 一字之师是什么意思| 做梦梦见兔子是什么意思| 如履薄冰是什么意思| 机关党委是干什么的| h型高血压什么意思| 富勒烯是什么| 孕妇白蛋白偏低是什么意思| 男人头发硬说明什么| 十滴水是什么| 爱新觉罗是什么民族| 西游记是一部什么小说| 尿毒症的尿是什么颜色| 什么的山顶| 小儿磨牙是什么原因引起的| prime是什么意思| 薄如蝉翼是什么意思| 财代表什么生肖| 好嘛是什么意思| 手皮脱皮是什么原因| 祸水什么意思| 拉肚子最好吃什么食物| 积福是什么意思| 表虚不固是什么意思| 兔子吃什么蔬菜| 脸热发红是什么原因| 古代医生叫什么| 琥珀色是什么颜色| 什么夕阳| 黄豆吃多了有什么坏处| 内热是什么意思| 为什么乳晕会变大| 裙带菜是什么| 对象是什么意思| 女性甲状腺挂什么科| 毛躁是什么意思| 乌龟王八甲鱼鳖有什么区别| 什么是心律失常| 梦见自己死了又活了是什么意思| 什么是机械键盘| 头一直疼是什么原因| 鼻子无故出血什么原因| 流光是什么意思| 母胎单身什么意思| 灰水是什么| 痛经吃什么药好| 皂角米是什么东西| 酸入肝是什么意思| 侯亮平是什么级别| 脑梗吃什么水果| 甲状腺1度肿大是什么意思| 北极熊为什么不怕冷| 是谁在敲打我窗是什么歌| 心脏早搏什么症状| 肚子疼吃什么食物好| 驿什么意思| 专项变应原筛查是什么| 三叉神经痛吃什么药效果最好| 白带带血丝是什么原因| 什么是花胶| 嘴唇上火吃什么药| 眉中间有竖纹代表什么| 激素吃多了对身体有什么副作用| 乳糖不耐受什么意思| 受用是什么意思| 什么坚果适合减肥吃| 软化血管吃什么药最好| 农历正月初一是什么节| 上海话娘娘是什么意思| 人为什么会打嗝| 血清铁蛋白是检查什么| 本我是什么意思| 肝功七项查的是什么| 手术后吃什么水果| 萎了是什么意思| 涨价是什么意思| 满族不吃什么肉| 沧海是什么意思| 促甲状腺素低是什么原因| replay是什么牌子| 食是什么生肖| 可望不可求是什么意思| 牙髓炎吃什么药最有效| 尿蛋白阴性是什么意思| 七六年属什么生肖| 手串19颗代表什么意思| id医学上是什么意思| 舌头肥厚是什么原因| 1月份是什么星座| 荷叶和什么搭配最减肥| nlp是什么| 百度
Skip to content

github/emergency-pull-request-probot-app

Repository files navigation

Emergency PR GitHub App

This project is a probot app deploying to AWS Lambda using aws sam. The purpose of this app is to provide a way for developers to bypass approval and checks in order to merge an emergency change to the protected main branch while ensuring that this bypass doesn't go unnoticed by creating an issue and/or slack notification.

The app listens for Pull Request events where action=labeled and can do 4 things:

  1. Approve an emergency PR
  2. Merge the emergency PR, bypassing approvals and checks
  3. Create an issue to audit the emergency PR
  4. Send notification via slack

Each of the above can be toggled on or off using the following environment variables which are meant to be self explanatory: APPROVE_PR, MERGE_PR, CREATE_ISSUE, SLACK_NOTIFY Setting each of the above to true will enable the feature. Any other value will disable the feature.

To configure the emergency label this app is looking for, set EMERGENCY_LABEL env var.

The issue this app will create can be configured by setting the ISSUE_TITLE, and ISSUE_BODY_FILE. The ISSUE_BODY_FILE is a markdown file used to create the issue. The # in that file will be replaced with a link to the PR and display the PR#. That link will look like this...
#19

The slack notification can be configured by setting the SLACK_MESSAGE_FILE. There are some dynamic replacements in this file that occur before the message is sent:

  • #pr is replaced with the url to the pull request
  • #l is replaced with the label configured in EMERGENCY_LABEL
  • #i is replaced with the url to the issue created, if issue creation is enabled

Environment setup

Create GitHub App

Create the GH App in your org or repo. Define a client secrent. Generate a private key.

Grant repository permissions

Set Contents access to Read & write
Set Issues access to Read & write
Set Pull Requests access to Read & write

Grant organization permissions

Set members access to Read-only

Subscripe to events

Check Issues
Check Issue comment
Check Pull request

Allow app to bypass branch protection

If you want the app to merge the emergency PR, and have configured "Require status checks to pass before merging" in your branch protection rule, you will need to allow the app to bypass branch protection.

If you want the app to merge the emergency PR, and have configured "Restrict who can push to matching branches" in your branch projection rule, you will need to allow the app push access to the matching branches.

Once you have the bot user setup and the GitHub app configured you are ready to deploy!

Create a Slack App

  1. Navigate to your slack workspace http://<workspace-name>.slack.com/home
  2. In the menu on the left, under Other, click the API link
  3. Click Create an app
  4. Create the app using the manifest file emergency-pr-manifest.yml

Deployment

Get the following details about your GitHub app:

  • APP_ID
  • WEBHOOK_SECRET
  • PRIVATE_KEY (base64 encoded)

You will need to base64 encode the private key.

Get the following details about your Slack app:

  • SLACK_BOT_TOKEN

Also go find the SLACK_CHANNEL_ID for the channel you want to send notifications to.
You will need to configure the contents of the slack message by setting value of SLACK_MESSAGE_FILE and editing the contents of that file.

You will need to decide the label that this app looks for, the contents of the issue, and the assignee of the issue:

  • EMERGENCY_LABEL This is the label that indicates an emergency PR
  • ISSUE_TITLE This is the title of the issue created
  • ISSUE_BODY_FILE This is the file containing the body of the issue created
  • ISSUE_ASSIGNEES This is a comma separated list of the issue assignees

Optionally, you can define a team name in the AUTHORIZED_TEAM variable. The app will consider members of this team authorized to use this app. The app will add a comment on the PR if an user who is not a member of this team attemps to do any of the following:

  • Opens a PR with the TRIGGER_STRING in the body
  • Adds a PR comment with the TRIGGER_STRING in the body
  • Adds the EMERGENCY_LABEL to a PR

The comment will read:

@username is not authorized to apply the emergency label.

To make the emergency label permanent set EMERGENCY_LABEL_PERMANENT to true. Doing this will cause the app to reapply the emergency label if it is removed. To trigger the label (and therefore everything configured) set TRIGGER_STRING to the value you want the app to look for in PRs and PR comments.

  1. Setup your aws cli creds
  2. set your aws profile by running export AWS_PROFILE=<profile>
  3. run sam build
  4. run sam deploy --guided You will be prompted for inputs names similar to the environment variables above.

Subsequent deploys to the same stack to the default environment...

  1. run sam build
  2. run sam deploy

Local setup

Install dependencies

npm install

Copy .env-sample to .env and fill in the environment variables as needed. See above.

Start the server

npm start

Follow the instructions to register a new GitHub app.

Docker

# 1. Run npm install
npm install

# 2. Build container
docker build -t emergency-pull-request .

# 3. Srouce your .env file
export $(cat .env | xargs)

# 3. Start container
docker run \
    -e APP_ID=$APP_ID \
    -e PRIVATE_KEY=$PRIVATE_KEY \
    -e WEBHOOK_SECRET=$WEBHOOK_SECRET \
    -e APPROVE_PR=$APPROVE_PR \
    -e CREATE_ISSUE=$CREATE_ISSUE \
    -e MERGE_PR=$MERGE_PR \
    -e ISSUE_TITLE=$ISSUE_TITLE \
    -e ISSUE_BODY_FILE=$ISSUE_BODY_FILE \
    -e ISSUE_ASSIGNEES=$ISSUE_ASSIGNEES \
    -e EMERGENCY_LABEL=$EMERGENCY_LABEL \
    emergency-pull-request

Debugging locally

There are two options to debug locally.

Debug via unit tests

  1. Intall nyc and mocha: npm install -g nyc mocha
  2. From the VSCode RUN AND DEBUG menu select Mocha and click the green arrow to start debugging.

Debug by launching probot locally and sending it a payload

  1. Point your GitHub app to your local using something like smee.io
  2. Copy .env-sample to .env and populate with values specific for your GitHub app. For the PRIVATE_KEY replace newlines with \\n to make the string value a single line.
  3. From the VSCode RUN AND DEBUG menu select Launch Probot and click the green arrow to start debugging.

License

ISC

About

Bypass approval and checks in order to merge an emergency change to the main branch with audit controls.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors 4

  •  
  •  
  •  
  •  
茄子炒什么好吃 屁股疼是什么原因 大便粘稠吃什么药 a2是什么意思 肾炎是什么症状
过氧化氢是什么 女性夜尿多是什么原因 老人怕冷是什么原因 为什么左手会发麻 盐酸西替利嗪片主治什么
一箭双雕是指什么生肖 特朗普是什么星座 鹞是什么意思 益气固表是什么意思 怀孕初期不能吃什么
藠头是什么菜 什么是二级医院 巨峰葡萄为什么叫巨峰 安然无恙的恙是什么意思 沙门氏菌用什么药最好
蜂王浆什么时间吃最好hcv7jop7ns1r.cn 焦虑症有什么症状hcv9jop6ns0r.cn 战略纵深是什么意思hcv8jop4ns0r.cn 鱼油是什么鱼提炼的hcv8jop4ns5r.cn 无期是什么意思hcv8jop8ns5r.cn
食品级pp材质是什么hcv9jop5ns9r.cn 怀孕两个月出血是什么原因hcv7jop5ns4r.cn 马来西亚主食吃什么hcv9jop6ns6r.cn 身份证有什么用hcv8jop8ns6r.cn 男人脚肿是什么病的前兆hcv7jop9ns3r.cn
肝昏迷是什么症状hcv8jop7ns0r.cn lalabobo是什么牌子xianpinbao.com funfair是什么意思hcv9jop1ns0r.cn 什么是药品hcv9jop1ns7r.cn 站桩对身体有什么好处和功效hcv9jop4ns0r.cn
风湿病是什么原因造成的hcv9jop3ns5r.cn 加湿器加什么水最好hcv8jop8ns7r.cn 情绪价值是什么意思hcv8jop8ns3r.cn 白芨有什么作用和功效hcv8jop0ns4r.cn 手术后吃什么补品好hcv8jop8ns4r.cn
百度