{"id":15048104,"url":"https://github.com/github/emergency-pull-request-probot-app","last_synced_at":"2025-08-01T22:38:15.914Z","repository":{"id":65396076,"uuid":"477765179","full_name":"github/emergency-pull-request-probot-app","owner":"github","description":"Bypass approval and checks in order to merge an emergency change to the main branch with audit controls.","archived":false,"fork":false,"pushed_at":"2025-01-27T06:07:52.000Z","size":699,"stargazers_count":48,"open_issues_count":4,"forks_count":4,"subscribers_count":188,"default_branch":"main","last_synced_at":"2025-01-30T07:42:39.795Z","etag":null,"topics":["probot-app","pull-requests","services-engineering-team","services-toolbox"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/github.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-04T15:39:04.000Z","updated_at":"2025-01-09T19:59:12.000Z","dependencies_parsed_at":"2023-09-25T03:36:21.073Z","dependency_job_id":"4042465d-df7d-4d0b-b956-781a4f141339","html_url":"https://github.com/github/emergency-pull-request-probot-app","commit_stats":{"total_commits":147,"total_committers":3,"mean_commits":49.0,"dds":0.3877551020408163,"last_synced_commit":"3415a9f8c03fb75b3b230dee37021c6da501d2c6"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github%2Femergency-pull-request-probot-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github%2Femergency-pull-request-probot-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github%2Femergency-pull-request-probot-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/github%2Femergency-pull-request-probot-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/github","download_url":"https://codeload.github.com/github/emergency-pull-request-probot-app/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237224891,"owners_count":19275104,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["probot-app","pull-requests","services-engineering-team","services-toolbox"],"created_at":"2024-09-24T21:08:08.733Z","updated_at":"2025-08-01T22:38:15.901Z","avatar_url":"https://github.com/github.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Emergency PR GitHub App\n\nThis project is a probot app deploying to [AWS Lambda](https://aws.amazon.com/lambda/) using [aws sam](https://aws.amazon.com/serverless/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.\n\nThe app listens for [Pull Request events](https://docs.github.com/en/developers/webhooks-and-events/events/github-event-types#pullrequestevent) where action=`labeled` and can do 4 things:\n1. Approve an emergency PR\n1. Merge the emergency PR, bypassing approvals and checks\n1. Create an issue to audit the emergency PR\n1. Send notification via slack\n\nEach of the above can be toggled on or off using the following environment variables which are meant to be self explanatory:\n`APPROVE_PR, MERGE_PR, CREATE_ISSUE, SLACK_NOTIFY`\nSetting each of the above to `true` will enable the feature. Any other value will disable the feature.\n\nTo configure the emergency label this app is looking for, set `EMERGENCY_LABEL` env var.\n\nThe 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...  \n[#19](https://github.com/robandpdx-volcano/superbigmono/pull/19)\n\nThe 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:\n - `#pr` is replaced with the url to the pull request\n - `#l` is replaced with the label configured in `EMERGENCY_LABEL`\n - `#i` is replaced with the url to the issue created, if issue creation is enabled\n## Environment setup\n### Create GitHub App\nCreate the GH App in your org or repo. Define a client secrent. Generate a private key.\n#### Grant repository permissions\nSet Contents access to `Read \u0026 write`  \nSet Issues access to `Read \u0026 write`  \nSet Pull Requests access to `Read \u0026 write`  \n#### Grant organization permissions\nSet members access to `Read-only`\n#### Subscripe to events\nCheck `Issues`  \nCheck `Issue comment`  \nCheck `Pull request`\n\n#### Allow app to bypass branch protection\nIf 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.\n\nIf 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.\n\nOnce you have the bot user setup and the GitHub app configured you are ready to deploy!\n\n### Create a Slack App\n1. Navigate to your slack workspace `https://\u003cworkspace-name\u003e.slack.com/home`\n1. In the menu on the left, under `Other`, click the `API` link\n1. Click `Create an app`\n1. Create the app using the manifest file emergency-pr-manifest.yml\n## Deployment\nGet the following details about your GitHub app:\n- `APP_ID`\n- `WEBHOOK_SECRET`\n- `PRIVATE_KEY` (base64 encoded)\n\nYou will need to base64 encode the private key.\n\nGet the following details about your Slack app:\n- `SLACK_BOT_TOKEN`\n\nAlso go find the `SLACK_CHANNEL_ID` for the channel you want to send notifications to.  \nYou will need to configure the contents of the slack message by setting value of `SLACK_MESSAGE_FILE` and editing the contents of that file.\n\nYou will need to decide the label that this app looks for, the contents of the issue, and the assignee of the issue:\n- `EMERGENCY_LABEL`  This is the label that indicates an emergency PR\n- `ISSUE_TITLE`  This is the title of the issue created\n- `ISSUE_BODY_FILE`  This is the file containing the body of the issue created\n- `ISSUE_ASSIGNEES`  This is a comma separated list of the issue assignees\n\nOptionally, 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:  \n- Opens a PR with the `TRIGGER_STRING` in the body  \n- Adds a PR comment with the `TRIGGER_STRING` in the body  \n- Adds the `EMERGENCY_LABEL` to a PR  \n\nThe comment will read:  \n```\n@username is not authorized to apply the emergency label.\n```\n\nTo 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.\nTo 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.\n\n1. Setup your aws cli creds\n1. set your aws profile by running `export AWS_PROFILE=\u003cprofile\u003e`\n1. run `sam build`\n1. run `sam deploy --guided`\nYou will be prompted for inputs names similar to the environment variables above. \n\nSubsequent deploys to the same stack to the default environment...\n1. run `sam build`\n1. run `sam deploy`\n\n## Local setup\n\nInstall dependencies\n\n```\nnpm install\n```\n\nCopy .env-sample to .env and fill in the environment variables as needed. See above.\n\nStart the server\n\n```\nnpm start\n```\n\nFollow the instructions to register a new GitHub app.\n\n## Docker\n\n```sh\n# 1. Run npm install\nnpm install\n\n# 2. Build container\ndocker build -t emergency-pull-request .\n\n# 3. Srouce your .env file\nexport $(cat .env | xargs)\n\n# 3. Start container\ndocker run \\\n    -e APP_ID=$APP_ID \\\n    -e PRIVATE_KEY=$PRIVATE_KEY \\\n    -e WEBHOOK_SECRET=$WEBHOOK_SECRET \\\n    -e APPROVE_PR=$APPROVE_PR \\\n    -e CREATE_ISSUE=$CREATE_ISSUE \\\n    -e MERGE_PR=$MERGE_PR \\\n    -e ISSUE_TITLE=$ISSUE_TITLE \\\n    -e ISSUE_BODY_FILE=$ISSUE_BODY_FILE \\\n    -e ISSUE_ASSIGNEES=$ISSUE_ASSIGNEES \\\n    -e EMERGENCY_LABEL=$EMERGENCY_LABEL \\\n    emergency-pull-request\n```\n\n## Debugging locally\nThere are two options to debug locally.\n\n### Debug via unit tests\n1. Intall nyc and mocha: `npm install -g nyc mocha`\n1. From the VSCode `RUN AND DEBUG` menu select `Mocha` and click the green arrow to start debugging.\n\n### Debug by launching probot locally and sending it a payload \n\n1. Point your GitHub app to your local using something like smee.io\n1. 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.\n1. From the VSCode `RUN AND DEBUG` menu select `Launch Probot` and click the green arrow to start debugging.\n\n## License\n\n[ISC](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgithub%2Femergency-pull-request-probot-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgithub%2Femergency-pull-request-probot-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgithub%2Femergency-pull-request-probot-app/lists"}