Greenkeeper is a really popular tool that was made to monitor and automatically update npm dependencies. The objective of this guide is to show you how to combine it with Buddy.
How Greenkeeper works
To make Greenkeeper work, you have to integrate it with GitHub (for now it doesn’t integrate with any other git hosting provider) and your CI service. It’ll know what version of an npm package you’re using, what is available one and basing on that, it’ll create a proper issue or pull request.
When the new version of the npm package arrives and it’s out-of-range of what you have defined in the package.json.
Greenkeeper creates then a branch that updates your dependency, issue a pull request and invokes your CI service to test this branch. After successful tests, their results are displayed in the GitHub so that you can see whether it is safe to accept the upgrade request.
2. In-range update
When the new version of the npm package arrives and it’s compatible with the wildcard that you have in the package.json.
Greenkeeper creates a branch with a new version and invokes you CI service to test it. If the tests pass it means that your package.json content is okay. After that Greenkeeper will delete that branch. However, if the tests don’t pass, Greenkeeper will create an issue for you to fix the version of that dependency in your repo.
How to configure Greenkeeper with Buddy
WARNING: Greenkeeper has a number of requirements for each repository it is meant to watch:
- The repo must have a package.json in the repo root
- Issues must be enabled for the repo (careful: issues are disabled by default on forked repositories)
- Greenkeeper doesn’t support multiple package.json files per repo yet, but it does work with alle-style monorepos.
- If you do not have a paid subscription of Greenkeeper, the repo must be public
Add a new project in Buddy and select GitHub as your git hosting provider:
WARNING: It’s really important to first add a wildcard pipeline in Buddy before integrating the project with Greenkeeper
Add a new pipeline (choose On every push and * wildcard):
Add a test action in which you’ll execute tests, eg.
Install Greenkeeper on the repository’s parent organization or user account (you’ll only need to do this once per account).
INFO: If you’ve already installed it somewhere, click on Configure instead. You can then choose which organization or account to install the app in.
- Go to your profile settings —> Applications and click Configure next to the Greenkeeper
- Scroll down to the bottom of the page and grant access to the repository
INFO: Choosing All Repositories is not recommended
- Head to this repository and merge the Initial Pull Request
Congratulations! You have just integrated your repository with Greenkeeper. From now on, version of your dependecies will be automatically checked and tested.
WARNING: Can’t see integration with the service that you use? Drop a line to email@example.com with your use case and we’ll add it to our to-do list.