IMPORTANT: Please uninstall the production bot from your user account before continuing (otherwise multiple bots will respond to your comments)
To get your app running against GitHub
1.1 Go to your github developer settings
1.2 Create a new github app
Required fields are:
name
, which can be whatever you like, globally unique on githubhomepage url
, which can be set to anythingwebhook url
, which can be set to anything
Important fields are:
webhook secret
, set this todevelopment
Permissions
which should be set as defined in the app.yml, e.g. set read & write forRepository contents
,Issues
andPull Requests
, and read forRepository Metadata
Subscribe to Events
which should be set as defined in the app.yml, e.g. check the checkbox forIssue comment
- Ensure
Where can this GitHub App be installed?
is set toonly this account
You should now have an app created
- On the General Tab, Click
Generate Private Key
and download it for later usage, call it something likeallcontributorsbot.pem
- On the Install Tab, Install the app/bot on your user
Create a file named .env
with the following template:
APP_ID=
WEBHOOK_SECRET=development
PRIVATE_KEY=
Values
APP_ID
, you can get this from the General tab on the developer settings for your appWEBHOOK_SECRET
, leave as development (you set this on app setup)PRIVATE_KEY
when you generated the private key from your app, you should have aallcontributorsbot.pem
file locally (or similar). runopenssl base64 < allcontributorsbot.pem | tr -d '\n' | pbcopy
on the file which will copy the base64 contents onto your clipboard, paste that into the line forPRIVATE_KEY
- Setup a repository under your name (the name on github where the bot is installed)
- Enable issues and pull requests
- Create an issue
- Comment on the issue:
@all-contributors please add @jakebolam for design
(replace @jakebolam with your username)
To verify if the bot should have seen this goto your app settings. On the Advanced Tab, Click the most recent deliver to see the payload. It should look something like this:
. Copy the payload and save it locally in a file called test-webhook-payload.json
. Also make note of the headers under the 'Headers' section.
- Install the node modules for the bot
yarn install
- Run the bot
yarn start
- Curl the bot (or use Postman, using the headers you got from the previous step and the content from
test-webhook-payload.json
) If you're usingcurl
, this will look something like this:
curl -vX POST http://localhost:3000/ -d @test-webhook-payload.json \
--header "Content-Type: application/json" \
--header "User-Agent: GitHub-Hookshot/4d63832" \
--header "X-GitHub-Delivery: 413857f0-8b61-11eb-92be-566b7aa5f6ee" \
--header "X-GitHub-Event: issue_comment" \
--header "X-GitHub-Hook-ID: 297478976" \
--header "X-GitHub-Hook-Installation-Target-ID: 105785" \
--header "X-GitHub-Hook-Installation-Target-Type: integration" \
--header "X-Hub-Signature: sha1=ed222e6750dc2954a422ed8dd371f9da66368104" \
--header "X-Hub-Signature-256: sha256=04d0943f20545ac8df974466c502e4b9743d3618149b03f4ea1a9e658bf31fd0"
If there are no errors in the bot console, check your github test issue to see the bot respond 🎉
Using smee.io
Alternatively, instead of having to mock the webhook payload using curl
, you can add an additional environment variable called WEBHOOK_PROXY_URL
and set it to a smee.io channel URL.
Once you've done that, set the Webhook URL for you app in GitHub to the same channel URL and, after a server restart, your bot will be able to directly respond to incoming webhooks.