Skip to content

Instantly share code, notes, and snippets.

@tibotiber
Created October 5, 2016 15:28
Show Gist options
  • Save tibotiber/cd933537b990c7a5466c2f1e7a309efb to your computer and use it in GitHub Desktop.
Save tibotiber/cd933537b990c7a5466c2f1e7a309efb to your computer and use it in GitHub Desktop.
Medium post content (8/8/2016)
#!/bin/bash
# print outputs and exit on first failure
set -xe
if [ $TRAVIS_BRANCH == "master" ] ; then
# setup ssh agent, git config and remote
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/travis_rsa
git remote add deploy "travis@webhost.planecq.xyz:/var/www/planecq.com"
git config user.name "Travis CI"
git config user.email "travis@planecq.com"
# commit compressed files and push it to remote
rm -f .gitignore
cp .travis/deployignore .gitignore
git add .
git status # debug
git commit -m "Deploy compressed files"
git push -f deploy HEAD:master
elif [ $TRAVIS_BRANCH == "staging" ] ; then
# setup ssh agent, git config and remote
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/travis_rsa
git remote add deploy "travis@webhost.planecq.xyz:/var/www/planecq.xyz"
git config user.name "Travis CI"
git config user.email "travis@planecq.com"
# commit compressed files and push it to remote
rm -f .gitignore
cp .travis/deployignore .gitignore
git add .
git status # debug
git commit -m "Deploy compressed files"
git push -f deploy HEAD:master
else
echo "No deploy script for branch '$TRAVIS_BRANCH'"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment