Before you start
You need:1. Define a source operation to update your dependencies
To facilitate updating your dependencies in your project, define a source operation in your.upsun/config.yaml file
depending on your dependency manager:
- Composer
- npm
- Yarn
- Go
- Pipenv
- Bundler
.upsun/config.yaml
2. Automate your dependency updates with a cron job
After you’ve defined a source operation to update your dependencies on your project, you can automate it using a cron job. Note that it’s best not to run source operations on your production environment, but rather on a dedicated environment where you can test changes. Make sure you have the Upsun CLI installed and an API token so you can run a cron job in your app container.- Set your API token as a top-level environment variable:
- From the CLI
- From the Console
Run the following command:
- Add a build hook to your app configuration to install the CLI as part of the build process:
.upsun/config.yaml
- Then, to configure a cron job to automatically update your dependencies once a day, use a configuration similar to the following:
.upsun/config.yaml
development environment with its parent
and then runs the update source operation defined previously.
3. Configure notifications about dependency updates
To get notified every time a source operation is triggered and therefore every time a dependency is updated, you can configure activity scripts or webhooks.Notifications through an activity script
After you’ve defined a source operation to update your dependencies on your project, you can configure an activity script to receive notifications every time a dependency update is triggered.Example
You want to get notified of every dependency update through a message posted on a Slack channel. To do so, follow these steps:-
In your Slack administrative interface, create a new Slack webhook.
You get a URL starting with
https://hooks.slack.com/. -
Replace
SLACK_URLin the following.jsscript with your webhook URL. -
Add the following code to a
.jsfile: -
Run the following Upsun CLI command:
Optional: to only get notifications about specific environments, add the following flag to the command:
--environments=your_environment_name.
Notifications through a webhook
After you’ve defined a source operation to update your dependencies on your project, you can configure a webhook to receive notifications every time a dependency update is triggered. Webhooks allow you to host a script yourself externally. This script receives the same payload as an activity script and responds to the same events, but can be hosted on your own server and in your own language. To configure the integration between your webhook and your source operation, run the following Upsun CLI command:--environments=your_environment_name.
To test the integration and the JSON response,
you can generate a URL from a service such as webhook.site
and use the generated URL as URL_TO_RECEIVE_JSON.
This URL then receives the JSON response when a source operation is triggered.
Anytime a dependency is updated via a source operation,
the webhook now receives a POST message.
This POST message contains complete information about the entire state of the project at that time.