Skip to content

Instantly share code, notes, and snippets.

@jpalala
Created June 1, 2015 12:33
Show Gist options
  • Save jpalala/434be56203b81af6d95a to your computer and use it in GitHub Desktop.
Save jpalala/434be56203b81af6d95a to your computer and use it in GitHub Desktop.
Python script to run jekyll build and copy _site to your public folder
#!/usr/bin/env python
# place this file into your jekyll root directory, to run: python simple_jekyll_deployer.py
import os, sys
from time import sleep
def can_access( directory ):
try:
os.listdir(directory)
except OSError:
return False
#change this to your public directory
public_dir = '/var/www/html/example.com/public'
print "Running Jekyll Build:"
os.system('jekyll build');
sleep(0.5)
if( can_access(public_dir) != False):
print "Copying data to %s." % public_dir
os.system('cp -Rf _site/* %s' % public_dir )
else:
print "Public Directory: %s" % public_dir + " is not accessible"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment