59 lines
2.2 KiB
Bash
Executable File
59 lines
2.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# FROM: https://raw.githubusercontent.com/maxheld83/ghpages/master/LICENSE
|
|
# MIT License
|
|
|
|
# Copyright (c) 2019 Maximilian Held
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
# of this software and associated documentation files (the "Software"), to deal
|
|
# in the Software without restriction, including without limitation the rights
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
# copies of the Software, and to permit persons to whom the Software is
|
|
# furnished to do so, subject to the following conditions:
|
|
|
|
# The above copyright notice and this permission notice shall be included in all
|
|
# copies or substantial portions of the Software.
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
# SOFTWARE.
|
|
|
|
|
|
set -e
|
|
|
|
source ./build_dir
|
|
|
|
echo "#################################################"
|
|
echo "Changing directory to 'BUILD_DIR' $BUILD_DIR ..."
|
|
cd $BUILD_DIR
|
|
|
|
echo "#################################################"
|
|
echo "Now deploying to GitHub Pages..."
|
|
REMOTE_REPO="https://${GITHUB_PERSONAL_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" && \
|
|
REPONAME="$(echo $GITHUB_REPOSITORY| cut -d'/' -f 2)" && \
|
|
OWNER="$(echo $GITHUB_REPOSITORY| cut -d'/' -f 1)" && \
|
|
GHIO="${OWNER}.github.io" && \
|
|
if [[ "$REPONAME" == "$GHIO" ]]; then
|
|
REMOTE_BRANCH="master"
|
|
else
|
|
REMOTE_BRANCH="gh-pages"
|
|
fi && \
|
|
git init && \
|
|
git config user.name "${GITHUB_ACTOR}" && \
|
|
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" && \
|
|
if [ -z "$(git status --porcelain)" ]; then
|
|
echo "Nothing to commit" && \
|
|
exit 0
|
|
fi && \
|
|
git add . && \
|
|
git commit -m 'Deploy to GitHub Pages' && \
|
|
echo "REMOTE_BRANCH: $REMOTE_BRANCH" && \
|
|
git push --force $REMOTE_REPO master:$REMOTE_BRANCH && \
|
|
rm -fr .git && \
|
|
cd $GITHUB_WORKSPACE && \
|
|
echo "Content of $BUILD_DIR has been deployed to GitHub Pages." |