mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 00:46:03 +00:00
We leave the stuff under api/ alone for now, since we need to be able to ship it as a standalone thing. tools/post-receive wasn't using the function anyway. For push to master: Push this commit, update post-receive per instructions at the top of that file, then push the rest of the branch to confirm that the hook still works. No manual instructions for prod. (imported from commit 9bcbe14c08d15eda47d82f0b702bad33e217a074)
53 lines
2.1 KiB
Python
Executable File
53 lines
2.1 KiB
Python
Executable File
#!/usr/bin/env python
|
|
#
|
|
# Humbug's post-receive hook. There is a symlink
|
|
# from /srv/git/humbug.git/hooks/post-receive
|
|
# to ~humbug/humbug/tools/post-receive
|
|
# on git.humbughq.com. So to deploy changes to this script, run
|
|
#
|
|
# ssh humbug@git.humbughq.com 'cd humbug; git pull'
|
|
#
|
|
# To send the Humbug notices, this script calls out to our
|
|
# for-distribution git hook (under api/integrations/); since the git
|
|
# hook needs to be in the same directory as the configuration script
|
|
# for the git hook, this means that we need to have a shared directory
|
|
# containing (a symlink to) both the the for-distribution git hook and
|
|
# the Humbug configuration; for the moment those are
|
|
# bots/githook-post-receive and bots/humbug_git_config.py,
|
|
# respectively. We need the intermediate symlink because the git hook
|
|
# looks for its configuration in the directory that it sits in, and
|
|
# api/integrations/git/ has the example configuration.
|
|
#
|
|
#
|
|
# The "post-receive" script is run after receive-pack has accepted a pack
|
|
# and the repository has been updated. It is passed arguments in through
|
|
# stdin in the form
|
|
# <oldrev> <newrev> <refname>
|
|
# For example:
|
|
# aa453216d1b3e49e7f6f98441fa56946ddcd6a20 68f7abf4e6f922807889f52bc043ecd31b79f814 refs/heads/master
|
|
#
|
|
# see contrib/hooks/ for a sample
|
|
|
|
import sys
|
|
import subprocess
|
|
|
|
def update_deployment(server, oldrev, newrev, refname):
|
|
subprocess.check_call(["ssh", server, "--", "env", "-u", "GIT_DIR",
|
|
"/home/humbug/humbug/tools/update-deployment",
|
|
oldrev, newrev, refname])
|
|
|
|
deployments = {
|
|
'refs/heads/prod': ('humbughq.com', 'prod'),
|
|
'refs/heads/master': ('staging.humbughq.com', 'master'),
|
|
'refs/heads/test-post-receive': ('staging.humbughq.com', 'master'),
|
|
}
|
|
|
|
for ln in sys.stdin:
|
|
oldrev, newrev, refname = ln.strip().split()
|
|
if refname in deployments:
|
|
(server, branch) = deployments[refname]
|
|
p = subprocess.Popen("/home/humbug/humbug/bots/githook-post-receive",
|
|
stdin=subprocess.PIPE)
|
|
p.communicate(input=ln)
|
|
update_deployment(server, oldrev, newrev, "origin/" + branch)
|