2019-09-01 05:16:43 +08:00
#!/bin/sh
set -e
2019-10-03 09:16:44 +08:00
REPO = ${ INPUT_REPO :- $GITHUB_REPOSITORY }
2019-09-03 10:38:29 +08:00
if [ -z " $INPUT_TARGET_BRANCH " ] ; then
2019-09-01 05:33:41 +08:00
echo "⛔️ Target branch not defined"
exit 1
fi
2019-09-03 10:38:29 +08:00
if [ ! -d " $INPUT_BUILD_DIR " ] ; then
2019-09-01 05:16:43 +08:00
echo "⛔️ Build dir does not exist"
exit 1
fi
2019-09-03 10:38:29 +08:00
echo " 🏃 Deploying $INPUT_BUILD_DIR directory to $INPUT_TARGET_BRANCH branch "
cd " $INPUT_BUILD_DIR "
2019-09-01 05:16:43 +08:00
git init
git config user.name " ${ GITHUB_ACTOR } "
git config user.email " ${ GITHUB_ACTOR } @users.noreply.github.com "
git add .
git commit --allow-empty -m 'Deploy to GitHub pages'
2019-10-03 09:16:44 +08:00
git push --force --quiet " https:// ${ GITHUB_PAT :- " x-access-token: $GITHUB_TOKEN " } @github.com/ ${ REPO } .git " " master: ${ INPUT_TARGET_BRANCH } "
2019-09-01 05:16:43 +08:00
rm -rf .git
2019-09-19 04:13:14 +08:00
# Tried https://developer.github.com/v3/repos/pages/#request-a-page-build
# but not working: { "message": "Resource not accessible by integration", "documentation_url": "https://developer.github.com/v3/repos/pages/#request-a-page-build" }
# curl -XPOST -H"Authorization: token ${GITHUB_TOKEN}" -H"Accept: application/vnd.github.mister-fantastic-preview+json" https://api.github.com/repos/${GITHUB_REPOSITORY}/pages/builds
2019-09-19 04:00:34 +08:00
2019-09-01 05:16:43 +08:00
cd " $GITHUB_WORKSPACE "
2019-09-03 10:38:29 +08:00
echo " 🎉 Content of $INPUT_BUILD_DIR has been deployed to GitHub Pages. "