Skip to content

Instantly share code, notes, and snippets.

@kleicht
Last active April 4, 2018 13:37
Show Gist options
  • Save kleicht/a0570ce87aed7ac7f87dc608f29b4e52 to your computer and use it in GitHub Desktop.
Save kleicht/a0570ce87aed7ac7f87dc608f29b4e52 to your computer and use it in GitHub Desktop.
deploy via github webhook
[
{
"id": "webhook",
"execute-command": "/home/karl/go/src/github.com/kleicht/REPO_NAME/redeploy.sh",
"command-working-directory": "/home/karl/go/src/github.com/kleicht/REPO_NAME",
"response-message": "I got the payload!",
"response-headers":
[
{
"name": "Access-Control-Allow-Origin",
"value": "*"
}
],
"pass-arguments-to-command":
[
{
"source": "payload",
"name": "head_commit.id"
},
{
"source": "payload",
"name": "pusher.name"
},
{
"source": "payload",
"name": "pusher.email"
}
],
"trigger-rule":
{
"and":
[
{
"match":
{
"type": "payload-hash-sha1",
"secret": "SECRET",
"parameter":
{
"source": "header",
"name": "X-Hub-Signature"
}
}
},
{
"match":
{
"type": "value",
"value": "refs/heads/master",
"parameter":
{
"source": "payload",
"name": "ref"
}
}
}
]
}
}
]

Don't forget to set POST webhook payload format to "application/json" (not form)

$ go get github.com/adnanh/webhook
$ sudo systemctl daemon-reload
$ sudo systemctl enable webhook
$ sudo service webhook start
$ journalctl -u webhook
[Unit]
Description=Go webhooks
[Service]
Restart=always
RestartSec=3
WorkingDirectory=/home/karl/
ExecStart=/home/karl/go/bin/webhook -hotreload -verbose
User=karl
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment