Github repo release monitor
A Github repo's release schedule can be unpredictable. If you want to monitor the new release of a Github project, instead of checking it manually each time, you can save time by setting up a monitoring task and get notified whenever a new release is posted.
In this tutorial, we'll use the awesome JsonPath Github repo as an example, and show you how to use CronDog to monitor its new releases, by consuming the public-facing Github release API endpoint.
2. Create a CronDog scheduled task
After logging into the CronDog dashboard, click New task on the All Tasks page. The task creation form opens with Request, Schedule, and Notifications sections.
Under the Request and Schedule sections, provide the following values:
| Field | Value | Notes |
|---|---|---|
| Task Name | JsonPath release monitor | The name of the task |
| URL | https://api.github.com/repos/json-path/JsonPath/releases?per_page=1 | Github API that returns release info for the JsonPath Github repo: https://github.com/json-path/JsonPath. You can replace the /json-path/JsonPath portion with the repo name of your interest. For more info about the API see here. |
| Request Method | GET | |
| Request Headers | None | No headers are needed |
| Schedule | Every 1 week | The task will run once every week |
This tells the task to fetch JsonPath project's release info from the Github API once every week.
3. Create email notification
The API response body will carry the release data in JSON format, note that we provided a per_page URL parameter to limit response with only 1 release entry, which should be the latest:
GET https://api.github.com/repos/json-path/JsonPath/releases?per_page=1
[
{
"url": "https://api.github.com/repos/json-path/JsonPath/releases/43993793",
"assets_url": "https://api.github.com/repos/json-path/JsonPath/releases/43993793/assets",
"upload_url": "https://uploads.github.com/repos/json-path/JsonPath/releases/43993793/assets{?name,label}",
"html_url": "https://github.com/json-path/JsonPath/releases/tag/json-path-2.6.0",
"id": 43993793,
"author": {
"login": "kallestenflo",
"id": 447970,
"node_id": "MDQ6VXNlcjQ0Nzk3MA==",
"avatar_url": "https://avatars.githubusercontent.com/u/447970?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/kallestenflo",
"html_url": "https://github.com/kallestenflo",
"followers_url": "https://api.github.com/users/kallestenflo/followers",
"following_url": "https://api.github.com/users/kallestenflo/following{/other_user}",
"gists_url": "https://api.github.com/users/kallestenflo/gists{/gist_id}",
"starred_url": "https://api.github.com/users/kallestenflo/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/kallestenflo/subscriptions",
"organizations_url": "https://api.github.com/users/kallestenflo/orgs",
"repos_url": "https://api.github.com/users/kallestenflo/repos",
"events_url": "https://api.github.com/users/kallestenflo/events{/privacy}",
"received_events_url": "https://api.github.com/users/kallestenflo/received_events",
"type": "User",
"site_admin": false
},
"node_id": "MDc6UmVsZWFzZTQzOTkzNzkz",
"tag_name": "json-path-2.6.0",
"target_commitish": "master",
"name": "",
"draft": false,
"prerelease": false,
"created_at": "2021-06-02T17:50:01Z",
"published_at": "2021-06-02T18:04:08Z",
"assets": [
],
"tarball_url": "https://api.github.com/repos/json-path/JsonPath/tarball/json-path-2.6.0",
"zipball_url": "https://api.github.com/repos/json-path/JsonPath/zipball/json-path-2.6.0",
"body": "",
"reactions": {
"url": "https://api.github.com/repos/json-path/JsonPath/releases/43993793/reactions",
"total_count": 2,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 1,
"rocket": 1,
"eyes": 0
}
}
]
You'll see the tag_name is json-path-2.6.0. Let us create an email notification so you can get notified whenever this field value changed.
Under the Notifications section, click the Add button next to the Email label:
The Add email notification dialog opens.
Then provide the following values in the dialog:
| Field | Value | Notes |
|---|---|---|
| Source | Response Body (JSON) | Parse the API response as JSON payload |
| JSON path | [0]["tag_name"] | The location of the attribute we are evaluating against, i.e. the tag_name field of the first entry in the list. |
| Comparison | value has changed | |
| To | Your email address | |
| Subject | JsonPath has a new release! | The email subject |
| Message | You can leave this field as-is | The email body |
This tells CronDog to check the tag_name field of the first entry in the release list, send an email notification whenever the value changed.
Click Save. The new email notification appears under the Notifications section.
4. Save task
Click Create at the bottom of the task creation page.
After the task is created, CronDog opens the task detail page with the status set to Active.
5. Test task
To make sure your task settings such as URL and notification rules are properly configured, it's recommended to test your task at least once.
You can perform the test by clicking Run now at the top of the task page. Run now triggers the HTTP request right away and evaluates all configured notification conditions.
If everything went smooth, you should see the release data appear in the Response Body section of the execution detail:
You would also receive the email notification the first time the task runs successfully since the response body value has changed from non-existent to some value.
Congratulations! You can now sit back and wait for the CronDog email notification whenever a new release is published for the Github repo.
