Skip to content

Instantly share code, notes, and snippets.

@adamsrog
Created October 28, 2015 16:19
Show Gist options
  • Save adamsrog/e4e5e4d0267e53264e4d to your computer and use it in GitHub Desktop.
Save adamsrog/e4e5e4d0267e53264e4d to your computer and use it in GitHub Desktop.
#!/bin/bash
# This script will go through each directory (excluding .git/ and ./) and run `jekyll build`,
# then deploy it to specified account contained in the .username file. It is assumed the scp
# connection is able to connect using a key pair.
# Get count of sites to build
sites=$(find . -type directory -maxdepth 1 | grep -v .git | sed -n '1!p' | wc -l)
echo "[i] Depolying Jekyll Sites: $sites"
echo "---------------------------------------------------------"
for d in $(find . -type directory -maxdepth 1 | grep -v .git | sed -n '1!p')
do
# Build the site
echo -n "[.] Processing $d... "
( cd $d && jekyll build ) | grep "Error";
echo "done."
# Deploy the site using scp
filename=$d/.username
while read -r line
do
name=$line
echo -n "[.] Deploying $d/_site as $name... "
(cd $d/_site && scp -r -q * $name@ntsi:public_html)
echo "[!] $name complete. Finished with code: $?"
echo "---------------------------------------------------------"
done < "$filename"
done
@adamsrog
Copy link
Author

Sample output

[i] Depolying Jekyll Sites:        8
---------------------------------------------------------
[.] Processing ./accelerateddefensivedriving.com... done.
[.] Deploying ./accelerateddefensivedriving.com/_site as acceldefdriving... stdin: is not a tty
[!] acceldefdriving complete. Finished with code: 0
---------------------------------------------------------
[.] Processing ./accelerateddefensivedrivingschoolonline.com... done.
[.] Deploying ./accelerateddefensivedrivingschoolonline.com/_site as accelerateddefen... stdin: is not a tty
[!] accelerateddefen complete. Finished with code: 0
---------------------------------------------------------
[.] Processing ./arizonadefensivedriving.education... done.
[.] Deploying ./arizonadefensivedriving.education/_site as arizonadefensive... stdin: is not a tty
[!] arizonadefensive complete. Finished with code: 0
---------------------------------------------------------
[.] Processing ./avoid-the-points-defensive-driving.com... done.
[.] Deploying ./avoid-the-points-defensive-driving.com/_site as avoid... stdin: is not a tty
[!] avoid complete. Finished with code: 0
---------------------------------------------------------
[.] Processing ./aztsi.education... done.
[.] Deploying ./aztsi.education/_site as aztsieducation... stdin: is not a tty
[!] aztsieducation complete. Finished with code: 0
---------------------------------------------------------
[.] Processing ./dds.education... done.
[.] Deploying ./dds.education/_site as ddseducation... stdin: is not a tty
[!] ddseducation complete. Finished with code: 0
---------------------------------------------------------
[.] Processing ./defensive-driving-school.com... done.
[.] Deploying ./defensive-driving-school.com/_site as defensivedriving... stdin: is not a tty
[!] defensivedriving complete. Finished with code: 0
---------------------------------------------------------
[.] Processing ./discountdefensivedrivingschoolonline.com... done.
[.] Deploying ./discountdefensivedrivingschoolonline.com/_site as discountdefensiv... stdin: is not a tty
[!] discountdefensiv complete. Finished with code: 0
---------------------------------------------------------

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment