forked from mirage/mirage-www
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis-mirage-deploy.sh
51 lines (51 loc) · 1.96 KB
/
.travis-mirage-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
51
if [ "$DEPLOY" != "1" ]; then
echo "Deployment not requested; set DEPLOY=1 to attempt deployment"
elif [ "$TRAVIS_PULL_REQUEST" != "" ] && [ "$TRAVIS_PULL_REQUEST" != "false" ]; then
echo "Deployment will not be performed on a pull request"
elif [ "$TRAVIS_BRANCH" != "master" ]; then
echo "Deployment will not be performed on pushes to the branch $TRAVIS_BRANCH; try pushing to master"
elif [ "$MIRAGE_BACKEND" != "xen" ]; then
echo "Deployment strategy for non-Xen targets is unknown; set MIRAGE_BACKEND to xen to attempt a Xen deployment"
exit 1
elif [ "$XSECRET_default_0" = "" ]; then
echo "Deployment secret is not known; cannot deploy"
exit 1
elif [ "$XENIMG" = "" ]; then
echo "Set XENIMG to the image name to copy (e.g. \"openmirageorg\" or \"mirageio\")"
exit 1
else
# OK, let's do this.
eval `opam config env`
ssh_config="Host mir-deploy github.com
Hostname github.com
StrictHostKeyChecking no
CheckHostIP no
UserKnownHostsFile=/dev/null"
export DEPLOYD="/tmp/${TRAVIS_REPO_SLUG}-deployment";
# setup ssh
opam install travis-senv
mkdir -p ~/.ssh
travis-senv decrypt > ~/.ssh/id_dsa
chmod 600 ~/.ssh/id_dsa
echo "$ssh_config" >> ~/.ssh/config
# configure git for github
git config --global user.email 'travis@openmirage.org'
git config --global user.name 'Travis the Build Bot'
git config --global push.default simple
# clone deployment repo
git clone git@mir-deploy:${TRAVIS_REPO_SLUG}-deployment ${DEPLOYD}
# remove and recreate any existing image for this commit
mkdir -p $DEPLOYD/xen/$TRAVIS_COMMIT
cp ${SRC_DIR}/${XENIMG}.xen ${SRC_DIR}/config.ml $DEPLOYD/xen/$TRAVIS_COMMIT
rm -f $DEPLOYD/xen/$TRAVIS_COMMIT/${XENIMG}.xen.bz2
bzip2 -9 $DEPLOYD/xen/$TRAVIS_COMMIT/${XENIMG}.xen
echo $TRAVIS_COMMIT > $DEPLOYD/xen/latest
# commit and push changes
cd $DEPLOYD && \
git add xen/$TRAVIS_COMMIT xen/latest && \
git commit -m "adding $TRAVIS_COMMIT for $MIRAGE_BACKEND" && \
git status && \
git clean -fdx && \
git pull --rebase && \
git push
fi