commit 0d36df9c1a25381897329b07d1dca9f28481410f
parent 4be3059060e17b6b1734212c6d1c5bcd31999290
Author: Georges Dupéron <georges.duperon@gmail.com>
Date: Wed, 22 Mar 2017 00:04:28 +0100
Auto-push to master successful builds on the dev branch.
Diffstat:
2 files changed, 51 insertions(+), 0 deletions(-)
diff --git a/.travis.yml b/.travis.yml
@@ -58,3 +58,6 @@ script:
after_success:
- raco pkg install --deps search-auto cover cover-coveralls
- raco cover -b -f coveralls -d $TRAVIS_BUILD_DIR/coverage .
+
+after_success:
+ - sh ./auto-push-master.sh
diff --git a/auto-push-master.sh b/auto-push-master.sh
@@ -0,0 +1,48 @@
+#!/bin/sh
+set -e
+set +x
+if test "$(git config remote.origin.url)" != "https://github.com/jsmaniac/phc-graph.git"; then
+ echo "Not on official repo, will not auto-push to master."
+elif test "$TRAVIS_PULL_REQUEST" != "false"; then
+ echo "This is a Pull Request, will not auto-push to master."
+elif test "$TRAVIS_BRANCH" != "dev"; then
+ echo "Not on dev branch (TRAVIS_BRANCH = $TRAVIS_BRANCH), will not auto-push to master."
+elif test -z "${encrypted_8fdb34b09f5e_key:-}" -o -z "${encrypted_8fdb34b09f5e_iv:-}"; then
+ echo "Travis CI secure environment variables are unavailable, will not auto-push to master."
+else
+ set -x
+ echo "Automatic push to master"
+
+ # Git configuration:
+ git config --global user.name "$(git log --format="%aN" HEAD -1) (Travis CI automatic commit)"
+ git config --global user.email "$(git log --format="%aE" HEAD -1)"
+
+ # SSH configuration
+ mkdir -p ~/.ssh
+ chmod 700 ~/.ssh
+ set +x
+ if openssl aes-256-cbc -K $encrypted_8fdb34b09f5e_key -iv $encrypted_8fdb34b09f5e_iv -in travis-deploy-key-id_rsa.enc -out ~/.ssh/travis-deploy-key-id_rsa -d >/dev/null 2>&1; then
+ echo "Decrypted key successfully."
+ else
+ echo "Error while decrypting key."
+ fi
+ set -x
+ chmod 600 ~/.ssh/travis-deploy-key-id_rsa
+ set +x
+ eval `ssh-agent -s`
+ set -x
+ ssh-add ~/.ssh/travis-deploy-key-id_rsa
+
+ # Push to the auto-git branch, which can then auto-push to master, after this build finished
+ repo_url="$(git config remote.origin.url)"
+ ssh_repo_url="$(echo "$repo_url" | sed -e 's|^https://github.com/|git@github.com:|')"
+ commit_hash="$(git rev-parse HEAD)"
+ git log --oneline --decorate --graph -10
+ git fetch origin auto-push
+ git checkout FETCH_HEAD
+ echo "$commit_hash" > commit_hash
+ git add commit_hash
+ git commit -m "Request to auto-push $commit_hash to master" --allow-empty
+ git log --oneline --decorate --graph -10
+ git push --quiet "$ssh_repo_url" HEAD:auto-push || true # do not cause a tantrum in case of race conditions.
+fi