Index

joshstock.in / ca03566

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

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
16421 Jan 2023 10:17ac5912bUpdate post-receiveJosh Stockin112G

Blob @ joshstock.in / post-receive

text/x-shellscript769 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"
9
10while read oldrev newrev ref
11do
12 if [ "$ref" = "refs/heads/$BRANCH" ];
13 then
14 echo "Ref $ref received. Deploying ${BRANCH} branch to production..."
15 mkdir $TARGET
16 git --work-tree=$TARGET --git-dir=$GIT_DIR checkout -f $BRANCH
17 echo "Running deploy script"
18 sudo $TARGET/deploy prod
19 echo "Removing deploy directory"
20 sudo rm -rf $TARGET
21 else
22 echo "Ref $ref received. Doing nothing: only the ${BRANCH} branch may be deployed on this server."
23 fi
24done
25