post-receive.example (view raw)
1#!/bin/sh
2
3# example git post-receive hook that i use to autobuild my website on push
4
5# setup paths
6export GEM_HOME=$HOME/gems
7export PATH=$GEM_HOME/bin:$PATH
8
9# set variables, change example.com to your website repo name
10GIT_REPO=$HOME/example.com.git
11TMP_GIT_CLONE=$HOME/tmp/example.com
12GEMFILE=$TMP_GIT_CLONE/Gemfile
13PUBLIC_WWW=/var/www/htdocs/example.com
14
15# change branch name to your main deploy branch
16git clone -b main "$GIT_REPO" "$TMP_GIT_CLONE"
17
18# build the site
19BUNDLE_GEMFILE=$GEMFILE bundle install
20BUNDLE_GEMFILE=$GEMFILE bundle exec jekyll build -s "$TMP_GIT_CLONE" -d "$PUBLIC_WWW"
21
22# genterate thumbnails
23{
24 cp "$TMP_GIT_CLONE/visual/thumbs.sh" "$PUBLIC_WWW/visual/thumbs.sh"
25 cd "$PUBLIC_WWW/visual"
26 sh thumbs.sh
27 rm thumbs.sh
28}
29
30rm -Rf "$TMP_GIT_CLONE"
31exit