-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
49 lines (44 loc) · 1.75 KB
/
.gitlab-ci.yml
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
image: python:2.7-jessie
stages:
- test
- notify
- deploy
run_tests:
stage: test
script:
- "pip install pipenv"
- "pipenv install --dev --system"
- "python test/test.py"
notify_build_failure:
stage: notify
script:
- "apt-get update -qq && apt-get install -y -qq curl"
- "curl -X POST -d 'message=\"backup_sweeper build failed\"' https://${HOME_API_USER}:${HOME_API_AUTHKEY}@michaelhollister.me/api/pushover"
when: on_failure
notify_build_success:
stage: notify
script:
- "apt-get update -qq && apt-get install -y -qq curl"
- "curl -X POST -d 'message=\"backup_sweeper build successful\"' https://${HOME_API_USER}:${HOME_API_AUTHKEY}@michaelhollister.me/api/pushover"
when: on_success
deploy_mediaserver:
stage: deploy
environment:
name: "home.michaelhollister.me"
url: "http://home.michaelhollister.me"
script:
- "apt-get update -qq && apt-get install -y -qq openvpn sshpass psmisc"
- "echo -e \"${OPENVPN_CONFIG}\" > home.ovpn"
- "openvpn --config home.ovpn --daemon" # connect vpn
- "sleep 30" # wait for connection
- "pip install pipenv"
- "pipenv install --dev --system"
- "ping -c 4 ${REMOTE_SERVER}" # test vpn connection
- "pyinstaller --distpath bin --onefile src/backup_sweeper.py" # build executable
# scp the binary
- "sshpass -p \"$REMOTE_PASSWORD\" scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ./bin/backup_sweeper ${REMOTE_USER}@${REMOTE_SERVER}:/usr/local/bin/backup_sweeper"
- "sshpass -p \"$REMOTE_PASSWORD\" ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_SERVER} /bin/chmod +x /usr/local/bin/backup_sweeper"
- "killall openvpn" # kill vpn connection
when: on_success
only:
- master