Created
February 29, 2012 14:34
-
-
Save smaboshe/1941231 to your computer and use it in GitHub Desktop.
Schedule a nanoc site to update via cron
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
SHELL=/bin/bash | |
#m h dom mon dow command | |
# Update every Monday at 06:00hrs | |
00 06 * * Mon /bin/bash -l -c 'cd /home/sites/nanoc_site && script/publish' |
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
*** LOCAL GEMS *** | |
adsf (1.1.1) | |
bundler (1.1.1, 1.0.22) | |
cri (2.2.1) | |
kramdown (0.13.5) | |
mime-types (1.17.2) | |
nanoc (3.3.2) | |
rack (1.4.1) | |
rake (0.9.2.2) | |
systemu (2.5.0) |
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
#!/bin/bash | |
# Redirect all output to a log file | |
# Ref: https://groups.google.com/forum/?fromgroups#!topic/nanoc/jd63isEH3H8 | |
exec 2>&1 >> log/publish.log | |
# Ref: http://beginrescueend.com/workflow/scripting/ | |
# Load RVM into a shell session *as a function* | |
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then | |
# First try to load from a user install | |
source "$HOME/.rvm/scripts/rvm" | |
elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then | |
# Then try to load from a root install | |
source "/usr/local/rvm/scripts/rvm" | |
else | |
printf "ERROR: An RVM installation was not found.\n" | |
fi | |
echo "START" | |
date | |
git checkout master | |
git pull | |
# Update gems | |
gem cleanup | |
bundle | |
# Remove the previously compiled nanoc site | |
rm -rfv .output | |
rm -rfv tmp | |
# (Re)Build the nanoc site | |
#bundle exec nanoc compile | |
nanoc | |
# Publish the nanoc site | |
#bundle exec nanoc deploy --target live | |
nanoc deploy --target live | |
# Tag the git repository and exit | |
git tag "`date +published_%Y-%m-%d_%H%M%S`" | |
git push --tags | |
date | |
echo "DONE" | |
# Leave a space | |
echo |
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
# Sample output from running the cron job | |
START | |
Mon Mar 19 01:21:01 EDT 2012 | |
Already up-to-date. | |
Cleaning up installed gems... | |
Attempting to uninstall nanoc-3.3.1 | |
Executables and scripts will remain installed. | |
Successfully uninstalled nanoc-3.3.1 | |
Attempting to uninstall cri-2.2.0 | |
Successfully uninstalled cri-2.2.0 | |
Attempting to uninstall bundler-1.0.22 | |
Unable to uninstall bundler-1.0.22: | |
Gem::InstallError: gem "bundler" is not installed | |
Attempting to uninstall adsf-1.0.1 | |
Successfully uninstalled adsf-1.0.1 | |
Clean Up Complete | |
Using rake (0.9.2.2) | |
Using rack (1.4.1) | |
Using adsf (1.1.1) | |
Using cri (2.2.1) | |
Using kramdown (0.13.5) | |
Using mime-types (1.17.2) | |
Using nanoc (3.3.2) | |
Using systemu (2.5.0) | |
Using bundler (1.1.rc.8) | |
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed. | |
removed directory: `.output' | |
Loading site data... | |
Compiling site... | |
sending incremental file list | |
./ | |
sent 40 bytes received 15 bytes 36.67 bytes/sec | |
total size is 0 speedup is 0.00 | |
Mon Mar 19 01:21:05 EDT 2012 | |
DONE |
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
ruby 1.9.3p125 (2012-02-16 revision 34643) [i686-linux] |
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
rvm 1.10.3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment