-
-
Notifications
You must be signed in to change notification settings - Fork 838
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
1,701 additions
and
336 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: build | ||
on: [push, pull_request] | ||
jobs: | ||
build: | ||
strategy: | ||
matrix: | ||
go-version: [1.14.x, 1.15.x] | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-go@v2 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
id: go | ||
|
||
- name: Build | ||
run: go build -v | ||
|
||
- name: Test | ||
run: go test -v ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
language: go | ||
|
||
go: | ||
- 1.13.x | ||
- 1.14.x | ||
- master | ||
|
||
os: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,26 @@ | ||
# Hook examples | ||
This page is still work in progress. Feel free to contribute! | ||
# Hook Examples | ||
|
||
Hooks are defined in a hooks configuration file in either JSON or YAML format, | ||
although the examples on this page all use the JSON format. | ||
|
||
🌱 This page is still a work in progress. Feel free to contribute! | ||
|
||
### Table of Contents | ||
|
||
* [Incoming Github webhook](#incoming-github-webhook) | ||
* [Incoming Bitbucket webhook](#incoming-bitbucket-webhook) | ||
* [Incoming Gitlab webhook](#incoming-gitlab-webhook) | ||
* [Incoming Gogs webhook](#incoming-gogs-webhook) | ||
* [Incoming Gitea webhook](#incoming-gitea-webhook) | ||
* [Slack slash command](#slack-slash-command) | ||
* [A simple webhook with a secret key in GET query](#a-simple-webhook-with-a-secret-key-in-get-query) | ||
* [JIRA Webhooks](#jira-webhooks) | ||
* [Pass File-to-command sample](#pass-file-to-command-sample) | ||
* [Incoming Scalr Webhook](#incoming-scalr-webhook) | ||
* [Travis CI webhook](#travis-ci-webhook) | ||
* [XML Payload](#xml-payload) | ||
* [Multipart Form Data](#multipart-form-data) | ||
* [Pass string arguments to command](#pass-string-arguments-to-command) | ||
|
||
## Incoming Github webhook | ||
```json | ||
|
@@ -30,7 +51,7 @@ This page is still work in progress. Feel free to contribute! | |
{ | ||
"match": | ||
{ | ||
"type": "payload-hash-sha1", | ||
"type": "payload-hmac-sha1", | ||
"secret": "mysecret", | ||
"parameter": | ||
{ | ||
|
@@ -150,7 +171,7 @@ Values in the request body can be accessed in the command or to the match rule b | |
{ | ||
"match": | ||
{ | ||
"type": "payload-hash-sha256", | ||
"type": "payload-hmac-sha256", | ||
"secret": "mysecret", | ||
"parameter": | ||
{ | ||
|
@@ -425,6 +446,57 @@ Travis sends webhooks as `payload=<JSON_STRING>`, so the payload needs to be par | |
] | ||
``` | ||
|
||
## JSON Array Payload | ||
|
||
If the JSON payload is an array instead of an object, `webhook` will process the payload and place it into a "root" object. | ||
Therefore, references to payload values must begin with `root.`. | ||
|
||
For example, given the following payload (taken from the Sendgrid Event Webhook documentation): | ||
```json | ||
[ | ||
{ | ||
"email": "[email protected]", | ||
"timestamp": 1513299569, | ||
"smtp-id": "<14c5d75ce93.dfd.64b469@ismtpd-555>", | ||
"event": "processed", | ||
"category": "cat facts", | ||
"sg_event_id": "sg_event_id", | ||
"sg_message_id": "sg_message_id" | ||
}, | ||
{ | ||
"email": "[email protected]", | ||
"timestamp": 1513299569, | ||
"smtp-id": "<14c5d75ce93.dfd.64b469@ismtpd-555>", | ||
"event": "deferred", | ||
"category": "cat facts", | ||
"sg_event_id": "sg_event_id", | ||
"sg_message_id": "sg_message_id", | ||
"response": "400 try again later", | ||
"attempt": "5" | ||
} | ||
] | ||
``` | ||
|
||
A reference to the second item in the array would look like this: | ||
```json | ||
[ | ||
{ | ||
"id": "sendgrid", | ||
"execute-command": "{{ .Hookecho }}", | ||
"trigger-rule": { | ||
"match": { | ||
"type": "value", | ||
"parameter": { | ||
"source": "payload", | ||
"name": "root.1.event" | ||
}, | ||
"value": "deferred" | ||
} | ||
} | ||
} | ||
] | ||
``` | ||
|
||
## XML Payload | ||
|
||
Given the following payload: | ||
|
@@ -518,3 +590,34 @@ Content-Disposition: form-data; name="thumb"; filename="thumb.jpg" | |
``` | ||
|
||
We key off of the `name` attribute in the `Content-Disposition` value. | ||
|
||
## Pass string arguments to command | ||
|
||
To pass simple string arguments to a command, use the `string` parameter source. | ||
The following example will pass two static string parameters ("-e 123123") to the | ||
`execute-command` before appending the `pusher.email` value from the payload: | ||
|
||
```json | ||
[ | ||
{ | ||
"id": "webhook", | ||
"execute-command": "/home/adnan/redeploy-go-webhook.sh", | ||
"command-working-directory": "/home/adnan/go", | ||
"pass-arguments-to-command": | ||
[ | ||
{ | ||
"source": "string", | ||
"name": "-e" | ||
}, | ||
{ | ||
"source": "string", | ||
"name": "123123" | ||
}, | ||
{ | ||
"source": "payload", | ||
"name": "pusher.email" | ||
} | ||
] | ||
} | ||
] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.