Serverless function to automatically add labels to Pull Requests based on the changed files
Serverless function to automatically add labels to Pull Requests based on the changed files
$ git clone https://github.com/rafaelalmeidatk/webhook-labeler
$ cd webhook-labeler
$ vercel
Create a GitHub personal token (instructions here) with the repo
scope. The user that generated the token should have permissions to see the target repo and add labels to the PRs.
Inside the Vercel dashboard, access the settings of the deployed project and add the following env variables:
GITHUB_TOKEN
: the token that you created on step 2GITHUB_SECRET
: a strong random string, this should not be public availableA server restart is required, you can do this deploying the code again
labeler.json
file to the target repo, inside the .github
folder (.github/labeler.json
). Config example:{
"labels": {
"core": ["src/**", "api/**"],
"docs": "docs/**"
}
}
application/json
Pull requests
ping
event will be sent to confirm if everything is correct.You can use the same Payload URL for multiple repos, as long as the user that generated the GitHub token has permissions to read and change labels for all these repos
Run yarn install
to install the deps and yarn dev
to start the local server (the Vercel CLI should be globally available).