From 94b31c0022d1b8d71a6a0b339adfe410792cb986 Mon Sep 17 00:00:00 2001 From: Thomas Chartron Date: Thu, 11 Nov 2021 16:02:47 +0100 Subject: [PATCH] add example deploy github script --- deploy-github.sh | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 deploy-github.sh diff --git a/deploy-github.sh b/deploy-github.sh new file mode 100644 index 0000000..073cc00 --- /dev/null +++ b/deploy-github.sh @@ -0,0 +1,39 @@ +#!/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;32mCommit change to main repository\033[0m\n" +git add . +git commit -m "update" +git push origin main + +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 +cp -a public_zola/* public/ +rm -rf public_zola + +# 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