dorakueyon

HUGOのプロジェクトをGithub Pagesにdeployするscriptで時短

HUGOのサイトをビルド/デプロイするシェルスクリプトを利用します.

#!/bin/sh

# If a command fails then the deploy stops
set -e

printf "\033[0;32mDeploying updates to GitHub...\033[0m\n"

# Build the project.
hugo # if using a theme, replace with `hugo -t <YOURTHEME>`

# Go To Public folder
cd public

# Add changes to git.
git add .

# Commit changes.
msg="rebuilding site $(date)"
if [ -n "$*" ]; then
	msg="$*"
fi
git commit -m "$msg"

# Push source and build repos.
git push origin master

HUGO official から援用

こちらのポストは上記スクリプトを試用するためのものです.

commitメッセージも引数で追加できます.

[dorakueyon]% ./build_and_deploy.sh "shell"
Deploying updates to GitHub...

                   | EN
+------------------+----+
  Pages            | 15
  Paginator pages  |  0
  Non-page files   |  0
  Static files     |  1
  Processed images |  0
  Aliases          |  0
  Sitemaps         |  1
  Cleaned          |  0

Total in 368 ms
[master b16d109] shell
 6 files changed, 284 insertions(+), 9 deletions(-)
 create mode 100644 posts/2019/12/28/hugodeployshell/index.html
Enumerating objects: 20, done.
Counting objects: 100% (20/20), done.
Delta compression using up to 4 threads
Compressing objects: 100% (9/9), done.
Writing objects: 100% (13/13), 3.95 KiB | 808.00 KiB/s, done.
Total 13 (delta 7), reused 0 (delta 0)
remote: Resolving deltas: 100% (7/7), completed with 6 local objects.
To https://github.com/dorakueyon/dorakueyon.github.io.git
   4668c54..b16d109  master -> master

時短ですね.