sh 自动gh-pages分支生成脚本

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh 自动gh-pages分支生成脚本相关的知识,希望对你有一定的参考价值。

#!/usr/bin/env bash

set -e
set -x

COMMIT=$(git rev-parse master)
TAG=$(git describe $(git rev-list --tags --max-count=1))
DATE=`date +%Y-%m-%d`

mkdir -p doc-building
cd doc-building
git init
mkdir -p doc-building
git checkout gh-pages 2>/dev/null || git checkout -b gh-pages
git pull ../ gh-pages

cd ..
git --work-tree=./doc-building checkout master -- .

cd doc-building
sed -i.bak '/doc/d' .gitignore; rm .gitignore.bak
echo "jekyll-cayman-theme" >> .gitignore
echo "src" >> .gitignore
echo "test" >> .gitignore
echo "scripts" >> .gitignore
yarn
npm run doc:build
if [ ! -d "jekyll-cayman-theme" ]; then
  git clone https://github.com/pietromenna/jekyll-cayman-theme.git --depth=1
fi
cd jekyll-cayman-theme
cat ../scripts/jekyll/_config.yml > _config.yml
cat ../scripts/jekyll/page-header.html > _includes/page-header.html
cat ../scripts/jekyll/page-footer.html > _includes/page-footer.html
rm -r _posts/ || true
cat > index.md << EndOfMessage
---
layout: default
---
EndOfMessage
cat ../README.md >> index.md
bundle install
jekyll build
cp -r ./_site/* ../

cd ..
git checkout README.md
rm -r ./src; rm -r ./test; rm -r ./scripts;
git add --all
git commit -m "$TAG $COMMIT $DATE" --no-verify
git push ../ gh-pages

echo "$TAG $COMMIT"
echo "documentation created on branch gh-pages"

以上是关于sh 自动gh-pages分支生成脚本的主要内容,如果未能解决你的问题,请参考以下文章

Github 页面是在具有 gh-pages 分支的 repo 的分支中自动创建的吗?

sh 自动将新版本的文档推送到gh-pages

创建github仓库的gh-pages分支

如何找到远程git仓库的默认分支?

sh gh-pages.sh

text 使用主分支保持gh-pages最新