Created
June 1, 2015 12:33
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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