Skip to content

Commit de4564f

Browse files
author
Matthew Fisher
committed
feat(managing-deis): add docs for deploy hooks
1 parent 9c9f012 commit de4564f

3 files changed

Lines changed: 58 additions & 0 deletions

File tree

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ pages:
5252
- Tuning Component Settings: managing-workflow/tuning-component-settings.md
5353
- Configuring Load Balancers: managing-workflow/configuring-load-balancers.md
5454
- Configuring DNS: managing-workflow/configuring-dns.md
55+
- Deploy Hooks: managing-workflow/deploy-hooks.md
5556
- Platform Logging: managing-workflow/platform-logging.md
5657
- Platform Monitoring: managing-workflow/platform-monitoring.md
5758
- Production Deployments: managing-workflow/production-deployments.md
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Deploy Hooks
2+
3+
Deploy hooks allow an external service to receive a notification whenever a new version of your app
4+
is pushed to Workflow. It’s useful to help keep the development team informed about deploys, while
5+
it can also be used to integrate different systems together.
6+
7+
After one or more hooks are setup, hook output and errors appear in your application’s logs:
8+
9+
```
10+
$ deis logs
11+
...
12+
2011-03-15T15:07:29-07:00 deis[api]: Deploy hook sent to http://deis.rocks
13+
```
14+
15+
Deploy hooks are a generic HTTP hook. An administrator can create and configure multiple deploy
16+
hooks by [tuning the controller settings][controller-settings] via the Helm chart.
17+
18+
## HTTP POST Hook
19+
20+
The HTTP deploy hook performs an HTTP POST to a URL. The parameters included in the request are the
21+
same as the variables available in the hook message: `app`, `release`, `release_summary`, `sha` and
22+
`user`. See below for their descriptions:
23+
24+
```
25+
app=secure-woodland&release=v4&release_summary=gabrtv%20deployed%35b3726&sha=35b3726&user=gabrtv
26+
```
27+
28+
Optionally, if a deploy hook secret key is added to the controller through
29+
[tuning the controller settings][controller-settings], a new `Authorization` header will be
30+
present in the POST request. The value of this header is computed as the [HMAC][] hex digest of the
31+
request URL, using the secret as the key.
32+
33+
In order to authenticate that this request came from Workflow, use the secret key, the full URL and
34+
the HMAC-SHA1 hashing algorithm to compute the signature. In Python, that would look something like
35+
this:
36+
37+
```python
38+
import hashlib
39+
import hmac
40+
41+
hmac.new("my_secret_key", "http://deis.rocks?app=secure-woodland&release=v4&release_summary=gabrtv%20deployed%35b3726&sha=35b3726&user=gabrtv", digestmod=hashlib.sha1).hexdigest()
42+
```
43+
44+
If the value of the computed HMAC hex digest and the value in the `Authorization` header are
45+
identical, then the request came from Workflow.
46+
47+
!!! important
48+
When computing the signature, ensure that the URL parameters are in alphabetic order. This is
49+
critical when computing the cryptographic signature as most web applications don't care about
50+
the order of the HTTP parameters, but the cryptographic signature will not be the same.
51+
52+
53+
[controller-settings]: tuning-component-settings.md#customizing-the-controller
54+
[hmac]: https://en.wikipedia.org/wiki/Hash-based_message_authentication_code

src/managing-workflow/tuning-component-settings.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ REGISTRATION_MODE | set registration to "enabled",
4545
GUNICORN_WORKERS | number of [gunicorn][] workers spawned to process requests (default: CPU cores * 4 + 1)
4646
RESERVED_NAMES | a comma-separated list of names which applications cannot reserve for routing (default: "deis, deis-builder, deis-workflow-manager")
4747
SLUGRUNNER_IMAGE_NAME | the image used to run buildpack application slugs (default: "quay.io/deisci/slugrunner:canary")
48+
DEIS_DEPLOY_HOOK_URLS | a comma-separated list of URLs to send [deploy hooks][] to.
49+
DEIS_DEPLOY_HOOK_SECRET_KEY | a private key used to compute the HMAC signature for deploy hooks.
4850
DEIS_DEPLOY_REJECT_IF_PROCFILE_MISSING | rejects a deploy if the previous build had a Procfile but the current deploy is missing it. A 409 is thrown in the API. Prevents accidental process types removal. (default: "false", allowed values: "true", "false")
4951
DEIS_DEPLOY_PROCFILE_MISSING_REMOVE | when turned on (default) any missing process type in a Procfile compared to the previous deploy is removed. When set to false will allow an empty Procfile to go through without removing missing process types, note that new images, configs and so on will get updated on all proc types. (default: "true", allowed values: "true", "false")
5052

@@ -128,6 +130,7 @@ API_VERSION | The version number Workflow Manager sends to the versions AP
128130
[builder]: ../understanding-workflow/components.md#builder
129131
[controller]: ../understanding-workflow/components.md#controller
130132
[database]: ../understanding-workflow/components.md#database
133+
[deploy hooks]: deploy-hooks.md#http-post-hook
131134
[Deployments]: http://kubernetes.io/docs/user-guide/deployments/
132135
[downward-api]: http://kubernetes.io/docs/user-guide/downward-api/
133136
[gunicorn]: http://gunicorn.org/

0 commit comments

Comments
 (0)