sh hugo部署

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh hugo部署相关的知识,希望对你有一定的参考价值。

#!/bin/sh

set -e

DIR=$(dirname "$0")

if [[ $(git status -s) ]]
then
    echo "The working directory is dirty. Please commit any pending changes."
    exit 1;
fi

DEFAULT_UPSTREAM=""
UPSTREAM=$(git remote -v | grep "upstream" | grep -v grep | cat)

if [ -z "$UPSTREAM" ]
then
  echo "Upstream not found. Configuring the upstream."
  git remote add upstream "$DEFAULT_UPSTREAM" &&
  git fetch --all
  echo "Upstream configured to point to $DEFAULT_UPSTREAM."
fi

echo "Deleting old publication"
rm -rf public
mkdir public
git worktree prune

echo "Checking out gh-pages branch into public"
git worktree add -B gh-pages public upstream/gh-pages
rm -rf public/*

echo "Generating site"
hugo --baseUrl "/"

echo "Updating gh-pages branch"
pushd public && git add --all && git commit -m "Publishing to gh-pages (deploy.sh)"

git push -f | cat

popd

echo "published"

以上是关于sh hugo部署的主要内容,如果未能解决你的问题,请参考以下文章

sh [Hugo为用户页面构建脚本] #github #hugo #build

sh Bash脚本将Hugo升级到给定版本

杂谈 | 在 macOS 上使用 Hugo + Coding 搭建个人博客

Hugo快速入门

Hugo快速入门

Hugo快速入门