Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

hooks: Add a push_git_ref post-deploy hook.

Alex Vandiverc519ba40fd32
diff --git a/puppet/zulip/files/hooks/post-deploy.d/push_git_ref.hook b/puppet/zulip/files/hooks/post-deploy.d/push_git_ref.hook
new file mode 100644
index 00000000000..22d0004641b
--- /dev/null
+++ b/puppet/zulip/files/hooks/post-deploy.d/push_git_ref.hook
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+
+set -e
+set -u
+
+if [ -z "${ZULIP_NEW_MERGE_BASE_COMMIT:-}" ]; then
+ echo "push_git_ref: Can't push because deploy is not from git!"
+ exit 0
+fi
+
+if ! repo=$(crudini --get /etc/zulip/zulip.conf push_git_ref repo); then
+ echo "push_git_ref: No repo set! Set push_git_ref.repo in /etc/zulip/zulip.conf"
+ exit 0
+fi
+
+if ! ref=$(crudini --get /etc/zulip/zulip.conf push_git_ref ref); then
+ echo "push_git_ref: No ref set! Set push_git_ref.ref in /etc/zulip/zulip.conf"
+ exit 0
+fi
+
+git push -f "$repo" "$ZULIP_NEW_MERGE_BASE_COMMIT:$ref"
diff --git a/puppet/zulip/manifests/hooks/push_git_ref.pp b/puppet/zulip/manifests/hooks/push_git_ref.pp
new file mode 100644
index 00000000000..e5bd5ae5cca
--- /dev/null
+++ b/puppet/zulip/manifests/hooks/push_git_ref.pp
@@ -0,0 +1,9 @@
+# @summary Push the merge_base to a git repo after deploy
+#
+class zulip::hooks::push_git_ref {
+ include zulip::hooks::base
+
+ zulip::hooks::file { [
+ 'post-deploy.d/push_git_ref.hook',
+ ]: }
+}