Index

joshstock.in / 5f6c164

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

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
13813 Jul 2022 20:4823d0748Make post-receive hook run deploy script as superuserJosh Stockin111G

Blob @ joshstock.in / post-receive

text/x-shellscript789 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 "Running deploy script"
19 sudo $TARGET/deploy prod
20 echo "Removing deploy directory"
21 rm -rf $TARGET
22 else
23 echo "Ref $ref received. Doing nothing: only the ${BRANCH} branch may be deployed on this server."
24 fi
25done
26