mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-04-04 10:29:34 +00:00
Add a fallback script to publish docs
Sometimes the github action that runs `sbt publish-website` fails, this script is a quick workaround to use locally.
This commit is contained in:
parent
9851b71c45
commit
789a632ce8
51
website/push-docs.sh
Executable file
51
website/push-docs.sh
Executable file
@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Creates the documentation website and pushes it to the branch
|
||||
# 'current-docs' in order to be published.
|
||||
#
|
||||
# It is a fallback, when `sbt publish-website` is not working due to
|
||||
# too large payloads (as it seems) that prohibit uploading through
|
||||
# githubs http api. Therefore this script uses git (over ssh).
|
||||
|
||||
set -o errexit -o pipefail -o noclobber -o nounset
|
||||
|
||||
cdir=$(pwd)
|
||||
# make sure we are in source root
|
||||
if [ "$cdir" != $(git rev-parse --show-toplevel) ]; then
|
||||
echo "Please go into the source root."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# make sure we are on branch 'current-docs'
|
||||
branch=$(git branch --show-current)
|
||||
if [ "$branch" != "current-docs" ]; then
|
||||
echo "Current branch is not 'current-docs', but $branch."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# check for dirty branch
|
||||
if [[ -n $(git status -s) ]]; then
|
||||
echo "Working dir is dirty. Abort."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
temp=$(mktemp -d)
|
||||
trap "{ rm -rf '$temp'; }" EXIT
|
||||
|
||||
echo "Cloning docspell into new location $temp"
|
||||
git clone git@github.com:eikek/docspell.git "$temp"
|
||||
cd "$temp" && git checkout --track origin/gh-pages
|
||||
|
||||
echo "Create new website from current working directory"
|
||||
cd $cdir && nix-shell website/shell.nix --run 'sbt make-website'
|
||||
|
||||
echo "Copying new site to target"
|
||||
cp -R "$cdir"/website/target/zola-site/* "$temp/"
|
||||
|
||||
echo "Showing the diff."
|
||||
cd "$temp" && git diff || true
|
||||
|
||||
echo "Pushing changes?"
|
||||
echo "Use C-c to quit. When continuing, changes are pushed!"
|
||||
read
|
||||
cd "$temp" && git add . && git commit -am 'Updated gh-pages' && git push origin gh-pages
|
Loading…
x
Reference in New Issue
Block a user