From b3a00ee9264de31bc901bcef3ab59dc21bb1ec4f Mon Sep 17 00:00:00 2001 From: Rico Date: Tue, 28 Mar 2023 18:20:32 +0200 Subject: [PATCH 1/2] docs: fix example json in template.md Adds missing bracket. Escapes quotes within a string. Reformats whole example. fixes #627 --- docs/Templates.md | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/docs/Templates.md b/docs/Templates.md index 12798f44..60789b92 100644 --- a/docs/Templates.md +++ b/docs/Templates.md @@ -9,21 +9,20 @@ In additional to the [built-in Go template functions and features][tt], `webhook In the example JSON template file below (YAML is also supported), the `payload-hmac-sha1` matching rule looks up the HMAC secret from the environment using the `getenv` template function. Additionally, the result is piped through the built-in Go template function `js` to ensure that the result is a well-formed Javascript/JSON string. -``` +```json +[ { "id": "webhook", "execute-command": "/home/adnan/redeploy-go-webhook.sh", "command-working-directory": "/home/adnan/go", "response-message": "I got the payload!", - "response-headers": - [ + "response-headers": [ { "name": "Access-Control-Allow-Origin", "value": "*" } ], - "pass-arguments-to-command": - [ + "pass-arguments-to-command": [ { "source": "payload", "name": "head_commit.id" @@ -37,29 +36,23 @@ Additionally, the result is piped through the built-in Go template function `js` "name": "pusher.email" } ], - "trigger-rule": - { - "and": - [ + "trigger-rule": { + "and": [ { - "match": - { + "match": { "type": "payload-hmac-sha1", - "secret": "{{ getenv "XXXTEST_SECRET" | js }}", - "parameter": - { + "secret": "{{ getenv \"XXXTEST_SECRET\" | js }}", + "parameter": { "source": "header", "name": "X-Hub-Signature" } } }, { - "match": - { + "match": { "type": "value", "value": "refs/heads/master", - "parameter": - { + "parameter": { "source": "payload", "name": "ref" } @@ -69,7 +62,6 @@ Additionally, the result is piped through the built-in Go template function `js` } } ] - ``` [w]: https://github.com/adnanh/webhook From dacc25f6125e12ce8a3a2c4789a57fcca4ee87d0 Mon Sep 17 00:00:00 2001 From: Rico Date: Wed, 20 Dec 2023 00:08:41 +0000 Subject: [PATCH 2/2] docs: unescape quotes of go template string --- docs/Templates.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Templates.md b/docs/Templates.md index 60789b92..9253b1fe 100644 --- a/docs/Templates.md +++ b/docs/Templates.md @@ -41,7 +41,7 @@ Additionally, the result is piped through the built-in Go template function `js` { "match": { "type": "payload-hmac-sha1", - "secret": "{{ getenv \"XXXTEST_SECRET\" | js }}", + "secret": "{{ getenv "XXXTEST_SECRET" | js }}", "parameter": { "source": "header", "name": "X-Hub-Signature"