Last active
July 1, 2022 18:19
-
-
Save yoichitgy/00357ef560f08a3eb96e to your computer and use it in GitHub Desktop.
A bash script to deploy GitHub Pages with Hugo.
This file contains 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 | |
while getopts p option | |
do | |
case $option in | |
p) opt_p=TRUE ;; | |
esac | |
done | |
if [ ! -d "public" ] | |
then | |
echo -e "\033[1;31mDirectory 'public' does not exist. Check whether you are in the hugo root directory.\033[0m" | |
exit 0 | |
fi | |
echo -e "\033[0;32mDeploying updates to GitHub...\033[0m" | |
# Generate the pages. | |
find public ! -name ".*" -delete | |
hugo -t angels-ladder | |
# Go to the submodule directory. | |
cd public | |
# Commit changes. | |
date="`date`" | |
git add -A | |
git commit -m "Rebuild the site on $date" | |
# Push to origin. | |
git push origin master | |
# Back to the original directory. | |
cd .. | |
# Commit and push the submodule SHA | |
git add public | |
git commit -m "Update the submodule SHA on 'public' directory on $date" | |
git push origin master | |
# Ping Sitemap | |
if [ "$opt_p" = TRUE ] | |
then | |
curl "http://www.google.com/ping?sitemap=https://yoichitgy.github.io/sitemap.xml" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks but it doesn't commit changes to the public remove i.e. xxx.github.io branch