aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/hook/README.md2
-rwxr-xr-xbin/hook/post-receive17
2 files changed, 19 insertions, 0 deletions
diff --git a/bin/hook/README.md b/bin/hook/README.md
index aebe5c6..4c90c7e 100644
--- a/bin/hook/README.md
+++ b/bin/hook/README.md
@@ -10,6 +10,8 @@ These scripts are used to fire and handle webhooks.
* `deploy.rb`: Verify time in from payload body (to prevent replay
attacks), execute `git pull`, execute `hugo --minify`, and finally
update the `htdocs` symlink.
+* `post-receive`: Example [Git][] `post-receive` hook.
[sha256]: https://en.wikipedia.org/wiki/SHA-2 "SHA256"
[hmac]: https://en.wikipedia.org/wiki/HMAC "Hashed Message Authentication Code"
+[git]: https://git-scm.com/ "Git version control software"
diff --git a/bin/hook/post-receive b/bin/hook/post-receive
new file mode 100755
index 0000000..63ff055
--- /dev/null
+++ b/bin/hook/post-receive
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+#
+# Example post-receive hook for server-side git repository.
+#
+# Note: you'll need to populate HOOK_URL and HOOK_HMAC_KEY
+#
+
+# set sane error mode
+set -eu
+
+# set env vars
+export HOOK_URL='https://example.com/hooks/deploy'
+export HOOK_HMAC_KEY="omitted"
+
+# trigger webhook
+exec /data/www/pablotron.org/data/git/pablotron.org/bin/hook/fire.rb