summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorKasra Bigdeli <[email protected]>2019-12-24 16:30:49 -0500
committerKasra Bigdeli <[email protected]>2019-12-24 16:30:49 -0500
commit335391d1de02e060e19938ba424c9aac73870b63 (patch)
tree8e5a5abeb5138c1f5aa2dbbe81bbe5a48db18776
parentb7b0cb98224dc69f3c0ed3f6c1789695a0c37667 (diff)
downloadcaprover-one-click-apps-335391d1de02e060e19938ba424c9aac73870b63.tar.gz
caprover-one-click-apps-335391d1de02e060e19938ba424c9aac73870b63.zip
Added publish script
-rwxr-xr-xpublish-from-actions.sh59
1 files changed, 59 insertions, 0 deletions
diff --git a/publish-from-actions.sh b/publish-from-actions.sh
new file mode 100755
index 0000000..acf95c8
--- /dev/null
+++ b/publish-from-actions.sh
@@ -0,0 +1,59 @@
+#!/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." \ No newline at end of file