]> jfr.im git - irc/freenode/web-7.0.git/blobdiff - deploy.sh
Update changuide.md
[irc/freenode/web-7.0.git] / deploy.sh
index 67c6770726e8193b73059ac961a82212dfb2dd2d..1410092245972b492d27cc98a2dc435edf4b9e5e 100755 (executable)
--- a/deploy.sh
+++ b/deploy.sh
@@ -1,14 +1,26 @@
 #!/bin/sh
 
+if [ ! -f .deploy-key ]; then exit; fi
 if [ -z "$TRAVIS_BRANCH" ]; then exit; fi
-if [ ! "$TRAVIS_BRANCH" = master ]; then exit; fi
-
-export GIT_SSH_COMMAND="ssh -i $(readlink -f .deploy-key)"
-git clone -b gh-pages git@github.com:freenode/web-7.0.git .deploy
-cd .deploy
-rm -rf *
-cp -r ../out/* .
-cp -r ../static .
+
+BRANCH_DIR="$TRAVIS_BRANCH"
+
+if [ "$TRAVIS_PULL_REQUEST" != false ]; then
+    if [ "$TRAVIS_BRANCH" != master ]; then exit; fi
+
+    BRANCH_DIR="pull-$TRAVIS_PULL_REQUEST"
+fi
+
+export SSH_KEYFILE="$(readlink -f .deploy-key)"
+export GIT_SSH="$(readlink -f ssh.sh)"
+git clone -b gh-pages git@github.com:freenode/web-7.0.git .deploy || exit 1
+cd .deploy || exit 1
+git config user.name travis
+git config user.email travis@nowhere
+git rm -r "$BRANCH_DIR/*"
+mkdir -p "$BRANCH_DIR"
+cd "$BRANCH_DIR" || exit 1
+cp -r ../../out/* .
 git add -A
 git commit -m "travis: $TRAVIS_COMMIT"
-git push
+git push || exit 1