-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
70 lines (65 loc) · 2.1 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
stages:
- build
- deploy
build-main:
stage: build
image: alpine
rules:
- if: $CI_COMMIT_BRANCH == "master" && $CI_PIPELINE_SOURCE != "merge_request_event"
before_script:
- apk add tar
script:
- mv src komposant
- tar cvf source.tar komposant
artifacts:
paths:
- source.tar
expire_in: 2 hours
build-branches:
stage: build
image: alpine
rules:
- if: $CI_COMMIT_BRANCH != "master" && $CI_PIPELINE_SOURCE != "merge_request_event"
before_script:
- apk add tar
script:
- mv src k_$CI_COMMIT_BRANCH
- tar cvf source.tar k_$CI_COMMIT_BRANCH
artifacts:
paths:
- source.tar
expire_in: 2 hours
deploy_to_branches:
stage: deploy
image: alpine
rules:
- if: $CI_COMMIT_BRANCH != "master" && $CI_PIPELINE_SOURCE != "merge_request_event"
environment:
name: $CI_COMMIT_BRANCH
url: https://dwarves.iut-fbleau.fr/~foucher/k_$CI_COMMIT_BRANCH/
before_script:
- apk add openssh-client
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
script:
- scp -o StrictHostKeyChecking=no source.tar [email protected]:/export/home/an21/foucher/public_html/
- ssh -o StrictHostKeyChecking=no [email protected] "cd public_html/;rm -rf k_$CI_COMMIT_BRANCH; tar xfv source.tar;rm source.tar;cp db_config.php k_$CI_COMMIT_BRANCH/includes/config.php"
deploy:
stage: deploy
image: alpine
environment:
name: prod
url: https://dwarves.iut-fbleau.fr/~foucher/komposant/
rules:
- if: $CI_COMMIT_BRANCH == "master" && $CI_PIPELINE_SOURCE != "merge_request_event"
before_script:
- apk add openssh-client
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
script:
- scp -o StrictHostKeyChecking=no source.tar [email protected]:/export/home/an21/foucher/public_html/
- ssh -o StrictHostKeyChecking=no [email protected] "cd public_html/;rm -rf komposant; tar xfv source.tar;rm source.tar;cp db_config.php komposant/includes/config.php"