forked from niccokunzmann/schulcloud-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
114 lines (92 loc) · 4.85 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#! /bin/bash
#export TESTDEPLOY=$( cat testdeploy )
if [ "$TRAVIS_BRANCH" = "master" ]
then
export DOCKERTAG=latest
else
# replace special characters in branch name for docker tag
export DOCKERTAG=$( echo $TRAVIS_BRANCH | tr -s "[:punct:]" "-" | tr -s "[:upper:]" "[:lower:]" )
fi
function buildandpush {
# build container default theme
docker build -t schulcloud/schulcloud-client:$DOCKERTAG -t schulcloud/schulcloud-client:$GIT_SHA .
# build container n21 theme
docker build -t schulcloud/schulcloud-client-n21:$DOCKERTAG -t schulcloud/schulcloud-client-n21:$GIT_SHA -f Dockerfile.n21 .
# build container open theme
docker build -t schulcloud/schulcloud-client-open:$DOCKERTAG -t schulcloud/schulcloud-client-open:$GIT_SHA -f Dockerfile.open .
# build container brb theme
docker build -t schulcloud/schulcloud-client-brb:$DOCKERTAG -t schulcloud/schulcloud-client-brb:$GIT_SHA -f Dockerfile.brb .
# Log in to the docker CLI
echo "$MY_DOCKER_PASSWORD" | docker login -u "$DOCKER_ID" --password-stdin
# take those images and push them up to docker hub
docker push schulcloud/schulcloud-client:$DOCKERTAG
docker push schulcloud/schulcloud-client:$GIT_SHA
docker push schulcloud/schulcloud-client-n21:$DOCKERTAG
docker push schulcloud/schulcloud-client-n21:$GIT_SHA
docker push schulcloud/schulcloud-client-open:$DOCKERTAG
docker push schulcloud/schulcloud-client-open:$GIT_SHA
docker push schulcloud/schulcloud-client-brb:$DOCKERTAG
docker push schulcloud/schulcloud-client-brb:$GIT_SHA
}
function deploytotest {
# build container default theme
# docker build -t schulcloud/schulcloud-client:$DOCKERTAG -t schulcloud/schulcloud-client:$GIT_SHA .
# take those images and push them up to docker hub
# docker push schulcloud/schulcloud-client:$DOCKERTAG
# docker push schulcloud/schulcloud-client:$GIT_SHA
# screw together config file for docker swarm
# eval "echo \"$( cat compose-client-test.dummy )\"" > docker-compose-client.yml
# copy config-file to server and execute mit travis_rsa
chmod 600 travis_rsa
# scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i travis_rsa docker-compose-client.yml [email protected]:~
# ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i travis_rsa [email protected] /usr/bin/docker stack deploy -c /home/linux/docker-compose-client.yml test-schul-cloud
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i travis_rsa [email protected] /usr/bin/docker service update --force --image schulcloud/schulcloud-client:develop test-schul-cloud_client
}
function deploytoprods {
chmod 600 travis_rsa
# open
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i travis_rsa [email protected] /usr/bin/docker service update --force --image schulcloud/schulcloud-client-open:latest open_client
# brabu
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i travis_rsa [email protected] /usr/bin/docker service update --force --image schulcloud/schulcloud-client-brb:latest brabu_client
# thueringen
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i travis_rsa [email protected] /usr/bin/docker service update --force --image schulcloud/schulcloud-client:latest thueringen_client
# demo
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i travis_rsa [email protected] /usr/bin/docker service update --force --image schulcloud/schulcloud-client:latest demo_client
}
function deploytostaging {
# copy config-file to server and execute mit travis_rsa
chmod 600 travis_rsa
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i travis_rsa [email protected] /usr/bin/docker service update --force --image schulcloud/schulcloud-client:$DOCKERTAG staging_client
}
function inform {
if [[ "$TRAVIS_EVENT_TYPE" != "cron" ]]
then
curl -X POST -H 'Content-Type: application/json' --data '{"text":":rocket: Die Produktivsysteme können aktualisiert werden: Schul-Cloud Client!"}' $WEBHOOK_URL_CHAT
fi
}
function inform_staging {
if [[ "$TRAVIS_EVENT_TYPE" != "cron" ]]
then
curl -X POST -H 'Content-Type: application/json' --data '{"text":":boom: Das Staging-System wurde aktualisiert: Schul-Cloud Client! https://staging.schul-cloud.org/version"}' $WEBHOOK_URL_CHAT
fi
}
# write version file
printf "%s\n%s\n%s" $TRAVIS_COMMIT $TRAVIS_BRANCH $TRAVIS_COMMIT_MESSAGE > ./version
openssl aes-256-cbc -K $encrypted_839866e404c6_key -iv $encrypted_839866e404c6_iv -in travis_rsa.enc -out travis_rsa -d
if [[ "$TRAVIS_BRANCH" = "master" && "$TRAVIS_PULL_REQUEST" = "false" ]]
then
buildandpush
inform
elif [ "$TRAVIS_BRANCH" = "develop" ]
then
buildandpush
deploytotest
elif [[ $TRAVIS_BRANCH = release* || $TRAVIS_BRANCH = hotfix* ]]
then
buildandpush
deploytostaging
inform_staging
else
echo "Nix wird deployt"
fi
exit 0