|
| 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 |
0 commit comments