Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
robcronin committed Mar 27, 2018
1 parent 1cfdd53 commit 6b38523
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions README.md
Expand Up @@ -3,11 +3,11 @@
This repo is set up to deploy 3 lambdas which will run 2 checks on your pull requests:


**Title Checker**
## Title Checker

Checks if your Pull Request Titles match a given format

**Time Checker**
## Time Checker

For any Pull Request merging into a given branch it will check that the time is ok i.e. prevents merging into production after certain hours

Expand Down Expand Up @@ -38,7 +38,7 @@ You will need an AWS account to deploy lambdas

You will need a GitHub token to post status updates. You can use your own account or you can create a separate account to post status updates (if a shared repo for example).

- On the account you choose generate a new [personal acess token](https://github.com/settings/tokens)
- On the account you choose, generate a new [personal acess token](https://github.com/settings/tokens)
- You only need to give it `repo:status` permissions
- Save this token somewhere for now

Expand All @@ -58,7 +58,7 @@ Your lambda will need to know the token and webhook secret you have just generat

- Go to [AWS Console](https://aws.amazon.com/console/)
- From `Services` choose `EC2`
- At the bottom of the left hand menu choose `Parameter Store`
- At the bottom of the left hand menu, choose `Parameter Store`
- Add `github_token` and `github_webhook_secret` here based on the values noted above (as a Secure String)


Expand All @@ -72,14 +72,14 @@ Setup this repo to deploy the lambdas
- Run `yarn`
- In [githubTimeStatus.js](./pull-request/functions/githubTimeStatus.js) edit:
- `REPOS`: `owner/repo-name` for any repos you wish the time checker to act on
- `BASE_BRANCH`: `branch` you wish the time check to apply to
- `BASE_BRANCH`: `branch` you wish the time check to apply to (e.g. `production`)
- Deploy the lambdas with `serverless deploy` or `yarn deploy`
- Copy the endpoint that prints after a successful deployment


## GitHub Webhook

Anytime you create or modify a pull request we want to activate the lambda. Github webhooks allow you specify to an endpoint to hit when certain events occur.
Anytime you create or modify a pull request we want to activate the lambda. Github webhooks allow you specify an endpoint to hit when certain events occur.

- In any repo you wish your lambda to respond to, go to settings and choose `Webhooks`
- Add a webhook with:
Expand All @@ -94,15 +94,15 @@ Anytime you create or modify a pull request we want to activate the lambda. Gith
- See the status update
- The default rules:
- Name Check will only only pass if the PR title has 'ROBC' and a '#' in it
- Time Check will only be active for pull requests into production and will pass between 8am-4pm GMT+1
- Time Check will only be active for pull requests into production and will pass between 8am-4pm (GMT+1)
- If it doesn't work, check the logs: `serverless logs -f githubWebhookListener -t`

## Force it to be used

- After it runs once in a repo it can be chosen as a Required status check on any protected branches
- Go to settings in the repo and choose `Branches`
- Choose/Make a protected branch
- Choose `Require status checks to pass before merging` and select these checks
- Choose/Create a protected branch
- Tick `Require status checks to pass before merging` and then select these checks


## Tweak it
Expand All @@ -115,14 +115,15 @@ Anytime you create or modify a pull request we want to activate the lambda. Gith

**GitHub Time Status**

- In [githubWebhookListener.js](./pull-request/functions/githubWebhookListener.js#104) change to your desired times
- Also in [serverless.yml](./pull-request/serverless.yml#34) change the times that the block/unblock times to your desired times
- In [githubWebhookListener.js](./pull-request/functions/githubWebhookListener.js#104), on line 104, change to your desired (block/unblock)times
- Also in [serverless.yml](./pull-request/serverless.yml#34), on line 34, change the times in the cron functions that specify when the block/unblock functions trigger for all pull requests


# Gotchas

- Generally when you redeploy, the endpoint will remain the same. However, I noticed on the odd occassion it will change and you will have to update your repo webhooks. I haven't figured out under what circumstances this occurs for yet
- Statuses are tied to given commits, not given pull requests. Therefore if you have multiple pull requests open for the same branch (e.g. staging and production) then the status will apply to both
- Statuses are tied to given commits, not given pull requests. Therefore if you have multiple pull requests open for the same branch (e.g. staging and production) then the status will apply to both. However if you don't set the time check as Required on staging then it won't block merging to staging
- If you set the status `Time of Day Check` to 'Required' then any new pull request can not be merged until it passes this check, which won't be until 8am the next day... To overcome [githubWebhookListener.js](./pull-request/functions/githubWebhookListener.js#104) checks the time of the pull request event listener so that any new pull request can pass/fail the time check as expected


# References
Expand Down

0 comments on commit 6b38523

Please sign in to comment.