-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
44 lines (41 loc) · 1.49 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
stages:
- gitcopy
- testdeploy
testdeploy:
image: 'alpine:latest'
stage: testdeploy
only:
- main
script:
# Setup SSH deploy keys
- 'which ssh-agent || ( apk add --no-cache openssh-client )'
- eval $(ssh-agent -s)
- echo "$DEPLOY_KEY_TEST_JWINF" | ssh-add -
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
# Stop server and upload
- ssh medald@jim.test.bwinf.de "cd medal/tasks/jwinf/jwinf-aufgaben-public ; git pull"
- ssh medald@jim.test.bwinf.de "cd medal/tasks/jwinf/_common/modules ; git pull"
- ssh medald@jim.test.bwinf.de "sudo /bin/systemctl restart medal && exit"
- ssh medald@jim.test.bwinf.de "sudo /bin/systemctl restart medalp && exit"
- sleep 30
- ssh medald@jim.test.bwinf.de "sudo /bin/systemctl status medal && exit"
- ssh medald@jim.test.bwinf.de "sudo /bin/systemctl status medalp && exit"
gitcopy:
image: bitnami/git
stage: gitcopy
only:
- main
variables:
GIT_DEPTH: 0
before_script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- mkdir -p ~/.ssh
- eval $(ssh-agent -s)
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
script:
- ssh-add <(echo "$GITHUB_DEPLOY_KEY_PRIVATE")
- git checkout $CI_COMMIT_BRANCH
- git fetch --all
- git reset --hard origin/$CI_COMMIT_BRANCH
- git push git@github.com:bwinf/jwinf-aufgaben-public.git