Skip to content

Instantly share code, notes, and snippets.

@moxak
Last active June 3, 2022 04:03
Show Gist options
  • Save moxak/0648064680aaa57fb08b03ed848a127a to your computer and use it in GitHub Desktop.
Save moxak/0648064680aaa57fb08b03ed848a127a to your computer and use it in GitHub Desktop.
GitHub Pagesへのデプロイを自動化するシェルスクリプト。
#!/bin/bash
USERNAME='moxak'
function publish() {
USERNAME=$1
ESC=$(printf '\033')
echo "---Build by hugo."
hugo --minify >/dev/null
echo "---Move and copy files."
mv content/*/*.png static/img/ &>/dev/null
cp CNAME docs/
echo "---git add & commit."
git add . >/dev/null
git commit -m "updated on `(date +"%Y/%m/%d")`" --allow-empty >/dev/null
echo "---git push to master."
git push origin master &>/dev/null
echo "---Finish."
echo -e "\n"
echo "---See an activity_log for deployments"
printf " ---> ${ESC}[36m%s${ESC}[m\n" "https://github.com/${USERNAME}/${USERNAME}.github.io/deployments/activity_log?environment=github-pages"
echo "---See an article for the latest commit"
printf " ---> ${ESC}[36m%s${ESC}[m\n" "https://${USERNAME}.github.io/"
}
publish $USERNAME | xargs -L 1 bash -c 'printf "[%s] %s\n" "$(date +%Y-%m-%d\ %H:%M:%S )" "$*" ' bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment