-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·50 lines (42 loc) · 1.18 KB
/
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
44
45
46
47
48
49
50
#!/bin/bash
set -e
# Only build on the master branch
if [ "$TRAVIS_PULL_REQUEST" != "false" ] || [ "$TRAVIS_BRANCH" != "master" ]; then
echo "Skipping deploy."
exit 0
fi
# Clone the deploy repo
COMMIT_AUTHOR_NAME="$(git show -s --format="%aN" master)"
COMMIT_AUTHOR_EMAIL="$(git show -s --format="%aE" master)"
COMMIT_MESSAGE="$(git show -s --format="%s" master)"
if [ ! -d target ]; then
git clone https://github.com/team-manage/team-manage.github.io.git target
cd target
git remote add origin-ssh [email protected]:team-manage/team-manage.github.io.git
else
cd target
git pull origin master
fi
git config user.name "$COMMIT_AUTHOR_NAME"
git config user.email "$COMMIT_AUTHOR_EMAIL"
cd ..
# Delete old files
rm -rf target/*
# Copy built files
cp -r $(ls -A _site | sed -e "s|^|_site/|") target
# Commit new changes
cd target
git add --all
git commit -m "$COMMIT_MESSAGE"
cd ..
# Decrypt the deploy key
openssl aes-256-cbc -K $encrypted_e653ea757db9_key -iv $encrypted_e653ea757db9_iv -in deploy.enc -out deploy -d
chmod 600 deploy
eval $(ssh-agent -s)
ssh-add deploy
# Push to the deploy repo
cd target
git push origin-ssh master
cd ..
# Finished
echo "Deploy successful."