Skip to content

Instantly share code, notes, and snippets.

@dbtlr
Last active January 6, 2017 19:02
Show Gist options
  • Save dbtlr/626267ba4369e848946fc62889f6b959 to your computer and use it in GitHub Desktop.
Save dbtlr/626267ba4369e848946fc62889f6b959 to your computer and use it in GitHub Desktop.
A git based deploy for a Jekyll site.

A post-receive hook designed to take a pushed jekyll git repository and deploy it to a web directoy on the server.

Uses a releases / current symlink to point to the current site.

Deploys would go to: ssh://user@10.0.0.0/var/repo/yourdomain.com.git

#!/bin/sh
RELEASE=$(date +%s)
WEB_DIR=/var/www/yourdomain.com
REPO_DIR=/var/repo/yourdomain.com.git
RELEASE_DIR=$WEB_DIR/releases/$RELEASE
git --work-tree=$WEB_DIR/src --git-dir=$REPO_DIR checkout -f
cd $WEB_DIR/src
bundle install --quiet --path ~/vendor/bundle
mkdir $RELEASE_DIR
bundle exec jekyll build -d $RELEASE_DIR
rm $WEB_DIR/current && ln -s $RELEASE_DIR $WEB_DIR/current
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment