Source Control Hooks
Source control hooks allow you to auto build your application when an event happens (such as a successful merge of a PR or commit on a branch). Source control hooks can be set to auto deploy once the build is successful, in addition they can be set to first check the "Status Checks" on the targeted source control repo to ensure that the commit successfully passed all tests and approval flows.
Github Callback
POST /apps/{appname}/builds/auto/github
Important: This end point should only be used by github during the callback phase. The body of this post must be a github webhook callback. In addition it must contain x-hub-signature which contains a HMAC digest of the content body and the secret be pre-defined randomly generated token contained within auto_builds table.
Github Auto-Build/Deploy
View Auto Build/Deploy Hook
GET /apps/{appname}/builds/auto
curl \
-H 'Authorization: ...' \
-X GET \
https://apps.akkeris.io/apps/app-space/builds/auto/github
200 "OK" Response
{
"app": {
"id": "62dc0fd3-2cba-4925-8fca-d1129d296d2c",
"name": "app-space"
},
"auto_deploy": true,
"branch": "master",
"created_at": "2016-08-23T13:48:36.024Z",
"id": "43f49726-25f7-41e1-80c2-0f8677e956b2",
"organization": {
"id": "akkeris",
"name": "26390735-3eaa-48d0-b673-4ebc9a19bd9c"
},
"repo": "https://github.com/akkeris/alamo-app-controller",
"site": "https://github.com",
"space": {
"id": "3911c0ec-e967-4497-8db5-54a52c5174b4",
"name": "default"
},
"status_check": true,
"updated_at": "2016-08-23T13:48:36.024Z",
"username": "trevorlinton"
}
Create Auto Build/Deploy Hook
POST /apps/{appname}/builds/auto
This end point will reassign an apps auto build/deploy settings, only one auto build/deploy may be assigned to an app. The "username" is your Github username (e.g., http://github.com/user), the "token" can be generated by going to github then going to your settings (Menu -> Settings), then clicking on "Personal Access Tokens" on the left hand side, and finally generate a new token. Be sure to include the following scopes/permissions when generating the token: repo (and all children scopes), admin:repo_hook (and all children scopes), and notifications.
Name | Type | Description | Example |
---|---|---|---|
repo | required string | The repo url to add a webhook onto, either github or gitlab | https://github.com/akkeris/reponame |
branch | required string | The branch name to auto build for | master |
status_check | optional bool | Whether to wait for all status checks prior to build (and potentially deploying). | false |
auto_deploy | optional bool | Whether to auto deploy (release) the code, this will wait for status_check as well if set. | true |
username | required string | The user id of the user requesting the hook to be added. | trevorlinton |
token | required string | The token from github to add the webhook, this is not persisted and used once. | ab832239defaa3298438abb |
CURL Example
curl \
-H 'Authorization: ...' \
-X POST \
https://apps.akkeris.io/apps/app-space/builds/auto \
-d '{"repo":"https://github.com/akkeris/repo","branch":"master","status_check":true,"auto_deploy":true,"username":"trevorlinton","token":"ab832239defaa3298438abb"}'
201 "Created" Response
{
"status":"successful"
}
Remove Auto Build/Deploy Hook
DELETE /apps/{appname}/builds/auto/github
This end point will remove the webhook and entry for the auto build information.
CURL Example
curl \
-H 'Authorization: ...' \
-X DELETE \
https://apps.akkeris.io/apps/app-space/builds/auto/github
200 "OK" Response
{
"status":"successful"
}