Index

joshstock.in / 88b7a34

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

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
4304 Jan 2020 12:1788b7a34Create new git hooks for automatic deploymentJosh Stockin1220N

Blob @ joshstock.in / pre-receive

text/x-shellscript618 bytesdownload raw
1#!/bin/bash
2
3# .git/hooks/pre-receive
4
5SCRIPTPATH=$(dirname $(realpath -s $0))
6BRANCH="master"
7
8while read oldrev newrev ref
9do
10 if [ "$ref" = "refs/heads/$BRANCH" ];
11 then
12 echo "Ref $ref received. Deploying ${BRANCH} branch to production..."
13 if [ ! git diff --name-only $1..$2 | grep 'post-receive' ]; then
14 echo "Updated post-receive hook detected. Installing..."
15 git archive $newrev | tar -x -C /tmp/newrev
16 cp /tmp/newrev/post-receive $SCRIPTPATH/post-receive
17 rm -rf /tmp/newrev
18 fi
19 else
20 echo "Ref $ref received. Doing nothing: only the ${BRANCH} branch may be deployed on this server."
21 fi
22done
23