Chronicler is an open source project started by a couple of engineers at The New York Times. Issues and Pull Requests are always welcome!
Feel free to open issues for bugs, feature requests, and general questions.
- What version of node.js/npm are you using (
node --version
andnpm --version
) ? - What did you expect to see?
- What did you see instead?
Pull requests are very welcome! Before submitting changes, please follow these guidelines:
- Check the open issues and pull requests for existing discussions.
- Open an issue to discuss a new feature.
- Write/run tests and lint your code.
- Open a Pull Request.
Unless otherwise noted, the Chronicler source files are distributed under the Apache 2.0-style license found in the LICENSE file.
Clone the repo and install dependencies.
$ git clone https://github.com/NYTimes/Chronicler.git
$ cd Chronicler
$ npm install
To test Chronicler locally with real GitHub Webhook events you'll need to use a tunneling service that creates public URLs to your local environment. We reccommend using the free tool, ngrok
.
- Download ngrok and move the file to the
chronicler
directory. - Unzip the ngrok file
unzip ./ngrok-file-name.zip
.
There are a few environment variables that need to be set and exported. These variables should be available from the node.js process.env
object.
Variable Name | Description | Default |
---|---|---|
GH_TOKEN |
The Github personal access token to use for this app. Used for authentication when making calls to the GitHub API. | - |
SECRET |
The GitHub Webhook secret passed along with every Webhooks request. Allows your app to authenticate the request and make sure the request is coming from a trusted source. Pick a secure secret or create one using a generator. | - |
APP_NAME (optional) |
Name of the app to send as the User-Agent value in the API requests. |
Chronicler |
PORT (optional) |
App port. | 8080 |
To start your enviroment for local testing, you'll need to first start the express server and then ngrok.
-
Run
npm run dev
. -
Run
./ngrok http :port_number:
with theport_number
matching the one you set as thePORT
environment variable or8080
if none was specified.$ ./ngrok http 8080
-
If everything is set up correctly, your node server should be running, and you should see the ngrok console up and running in the window.
-
Make note of the ngrok "Forwarding" address (e.x
https://943c6c27.ngrok.io
) displayed in the console. You'll be using this to set up the Webhook in the repo settings.
NOTE The ngrok "Forwarding" address changes everytime ngrok is started, so you'll need to update it in the repo webhook settings every time you stop/start ngrok.
With your local development environment ready, you can now set your repo up with the Webhook information needed to communicate with the local environment.
- From your repo page, click on the "Settings" tab.
- On the left hand side, click the "Webhooks" menu item.
- Click the "Add Webhook" button.
- Add the ngrok "Forwarding" address to the "Payload URL" field with the
/webhooks
path (e.x.http://943c6c27.ngrok.io/webhooks
). - From the "Content Type" dropdown menu, select
application/json
. - Set the "Secret" field equal to the
SECRET
environment variable value created earlier. - Under "Which events would you like to trigger this webhook?" check off the "Let me select individual events." This will expand the event options and you should select "Release" and "Pull Request."
- Ensure that "Active" is checked off, and click "Add webhook" at the bottom of the form.
- Celebrate 👏 👏 👏 You're now ready to start developing and testing your changes locally.
Anytime a pull request is merged in the repository you set up with your local version of Chronicler a webhook event will be sent to the ngrok endpoint provided. To test that your changes work as expected you should run through the following cases.
Use Case | Expected Outcome |
---|---|
No release note drafts exist and a pull request is merged | A new release note draft is created that contains the merged pull request title and PR number. The release note draft should have the title "NEXT RELEASE." |
A release note draft already exists and a pull request is merged | The merged release draft title and PR number are appended to the existing release note draft as an additional list item. |
Chronicler uses the git hooks via the husky
package to run tests and lint code before each commit. When making changes to the Chronicler codebase please make sure to lint and write tests against your work.