ttpages/run.sh

40 lines
743 B
Bash

#!/usr/bin/env bash
set -eo pipefail
check_command() {
command -v "$1" >/dev/null 2>&1
}
if ! check_command git; then
echo "git not found, please install it!"
exit 1
fi
if [ $# -ne 1 ]; then
echo "Usage: $(basename "$0") <path>"
exit 1
fi
git config --global user.email "support@ttnrtsite.me"
git config --global user.name "TTGit Automation Bot"
git config --global --add --bool push.autoSetupRemote true
git fetch
if ! git ls-remote --exit-code --heads origin pages; then
git checkout --orphan -f pages
git rm -rf .
else
git checkout -f pages
fi
if ! [ -d "$1" ]; then
echo "$1 does not exist! Try setting inputs.path"
exit 1
fi
cp -r "$1"/* . && rm -rf "$1"
git add -A
git commit -m "TTPages: Automated Update"
git push -u