Index

joshstock.in / c859aa8

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

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
13411 Jul 2022 19:33c859aa8Update deploy script to create temporary working dirJosh Stockin110G

Blob @ joshstock.in / post-receive

text/x-shellscript1126 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/joshstockin-deploy"
7GIT_DIR="/home/ubuntu/joshstockin.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 mkdir $TARGET
17 git --work-tree=$TARGET --git-dir=$GIT_DIR checkout -f $BRANCH
18 echo "Installing required Python modules"
19 sudo python3 -m pip install -r $TARGET/requirements.txt
20 echo "Compiling root HTML"
21 sudo $TARGET/root/compile.py $HTML_OUT
22 echo "Installing nginx configuration"
23 sudo $TARGET/nginx/copynginx prod
24 echo "Installing resty-gitweb configuration"
25 sudo install $TARGET/resty-gitweb.yaml /etc/resty-gitweb.yaml
26 echo "Removing deploy directory"
27 rm -rf $TARGET
28 else
29 echo "Ref $ref received. Doing nothing: only the ${BRANCH} branch may be deployed on this server."
30 fi
31done
32