blow/deploy-github.sh

40 lines
922 B
Bash
Raw Normal View History

2021-11-11 15:02:47 +00:00
#!/usr/bin/env bash
# If a command fails then the deploy stops
set -e
if [ -d "public" ]
then
echo -e "\033[0;32mRemoving public folder except .git and README.md and CNAME \033[0m\n"
cd public
find . -not -name '.git' -not -name 'README.md' -not -name 'CNAME' -delete
cd ..
fi
echo -e "\033[0;32mDeploying updates to GitHub pages repository\033[0m\n"
# Build the project to another directory because zola will delete the submodule /public otherwise
zola build --output-dir public_zola
#Now copy built files to public directory
2021-11-17 21:43:51 +00:00
cp -a public_zola/ public/
2021-11-11 15:02:47 +00:00
rm -rf public_zola
2021-11-13 12:12:37 +00:00
echo -e "\033[0;32mCommit change to main repository\033[0m\n"
git add .
2021-11-14 14:15:17 +00:00
git commit -am "update"
2021-11-13 12:12:37 +00:00
git push origin main
2021-11-11 15:02:47 +00:00
# Go To Public folder
cd public
# Add changes to git.
git add .
# Commit changes.
msg="update site content $(date)"
if [ -n "$*" ]; then
msg="$*"
fi
git commit -m "$msg"
# Push source
git push origin main