Index

joshstock.in / f5a1949

Source for serving and static templating/compiling of https://joshstock.in.

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
12313 Oct 2021 19:04370f1dbMerge branch 'deploy'Josh Stockin000G

Blob @ joshstock.in / post-receive

text/x-shellscript1030 bytesdownload raw
1#!/bin/bash
2
3# this file is automatically updated, although the pre-receive hook must be placed manually:
4# 'pre-receive' -> '.git/hooks/pre-receive'
5
6TARGET="/home/ubuntu/joshstock.in/deploy"
7GIT_DIR="/home/ubuntu/joshstock.in/project.git"
8BRANCH="master"
9HTML_OUT="/var/www/html"
10
11while read oldrev newrev ref
12do
13 if [ "$ref" = "refs/heads/$BRANCH" ];
14 then
15 echo "Ref $ref received. Deploying ${BRANCH} branch to production..."
16 git --work-tree=$TARGET --git-dir=$GIT_DIR checkout -f $BRANCH
17 echo "Installing required Python modules"
18 sudo python3 -m pip install -r $TARGET/requirements.txt
19 echo "Compiling root HTML"
20 sudo $TARGET/root/compile.py $HTML_OUT
21 echo "Installing nginx configuration"
22 sudo $TARGET/nginx/copynginx prod
23 echo "Installing resty-gitweb"
24 sudo install $TARGET/resty-gitweb.yaml /etc/resty-gitweb.yaml
25 else
26 echo "Ref $ref received. Doing nothing: only the ${BRANCH} branch may be deployed on this server."
27 fi
28done
29