Apply some simple checks on each PR.
We have 4 functions available:
- specification: It validates GitHub Pull Requests against some specifications:
body
should be at least 8 characters longtitle
should be at least 8 characters long
- label: It checks if there is a blocking label in the GitHub Pull Request
- if one blocking label (default:
Work In Progress
,Waiting For Change
,Waiting For Travis
) is found, PR is blocked - if no labels are defined in the PR, PR is blocked
- if no blocking labels are defined, PR is validated
- if one blocking label (default:
- fixup: It checks if there is some
fixup!
commits in the PR history- if at least one fixup commit are found, PR is blocked
- if no fixup commits are found, PR is validated
- autoMerge: It merges PR from @dependabot when the update it for a patch or a minor version
- the repo must have the auto merge option enabled
- Node.js 20
- Serverless CLI v3 (
npm install -g serverless@3
) - An AWS account
- Defined provider credentials
- Get a new personal access token on GitHub
- Set it in AWS Parameter Store as a
SecureString
with nameGITHUB_TOKEN
- Deploy the service using:
serverless deploy
By default
- it'll use the AWS profile
default
, but you can use your own using (be sure it's defined in your~/.aws/credentials
):serverless deploy --aws-profile myprofile
- it'll be deployed to the AWS region
eu-west-1
but you can change it using:serverless deploy --region us-east-1
Configure the webhook in the GitHub repository settings.
- In the Payload URL, enter the URL you received after deploying. It would be something like
https://<your_url>.amazonaws.com/dev/webhook
. - Choose the "application/json" in Content type.
- In the types of events to trigger the webhook, select "Let me select individual events", then select at least
Pull Requests
.
You can update some options from the serverless.yml
file:
NAMESPACE
: change the namespace used in the PR check (displayed at the bottom of each PR)CHECK_BODY_LENGTH
: change the minimun length of the body of the PRCHECK_TITLE_LENGTH
: change the minimun length of the title of the PRBLOCK_LABELS
: define which label will block a PR (coma separated strings)
This little project is part of the #NoServerNovember challenge.