-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtravis_deploy.sh
43 lines (32 loc) · 1.1 KB
/
travis_deploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Exit if any commands fail.
trap 'exit' ERR
# Echo each command as they are ran
set -v
# Pull requests and commits to other branches shouldn't try to deploy
if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
echo $TRAVIS_PULL_REQUEST
echo $TRAVIS_BRANCH
echo $SOURCE_BRANCH
exit 0
fi
eval "$(ssh-agent -s)"
mkdir -p ~/.ssh 2> /dev/null
echo $GIT_PRIVATE_KEY | base64 --decode > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-add ~/.ssh/id_rsa
# Push to prod if this is the prod branch
if [ "$TRAVIS_BRANCH" == "prod" ]; then
echo 'Deploying to prod'
# Delete the .git dir
rm -rf .git
# Delete the GIMP files
rm $(find . | grep .xcf\$)
# Make a tarball of stuff
tar -cvzf hw.tar.gz *
# And upload that stuff
scp -o StrictHostKeyChecking=no -r hw.tar.gz [email protected]:~/www/webdev/default/
ssh -o StrictHostKeyChecking=no [email protected] 'cd www/webdev; git reset --hard'
ssh -o StrictHostKeyChecking=no [email protected] 'cd www/webdev; git pull'
ssh -o StrictHostKeyChecking=no [email protected] 'cd www/webdev; git checkout prod'
fi
echo "Done travis_deploy.sh"