-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitlab1
More file actions
59 lines (51 loc) · 1.37 KB
/
Copy pathgitlab1
File metadata and controls
59 lines (51 loc) · 1.37 KB
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
stages:
- init
- build
- deploy
workflow:
rules:
- if : '$CI_COMMIT_TAG =~ /^stage-/'
when: always
- if: '$CI_COMMIT_TAG =~ /^prod-/'
when: always
init-job:
stage: init
script:
- echo "$CI_COMMIT_REF_NAME" | cut -d '-' -f1 >> .env
- echo VERSION="$CI_COMMIT_REF_NAME" | rev | cut -d '-' -f1 | rev >> .env
- echo SERVICE="$CI_COMMIT_REF_NAME" | sed 's/^\(stage\|prod\)-//' | sed 's/-[0-9.]*$//' >> .env
artifacts:
paths: ['.env']
build-job:
stage: build
before_script:
- SERVICE=$(echo "$CI_COMMIT_REF_NAME" | sed 's/^\(stage\|prod\)-//' | sed 's/-[0-9.]*$//')
- TAG=$(echo "$CI_COMMIT_REF_NAME" | rev | cut -d '-' -f1 | rev)
- export TAG
- export SERVICE
script:
- echo $SERVICE
- echo $TAG
- docker -H 192.168.1.193:2375 build -t $SERVICE:$TAG .
needs:
- init-job
deploy-job:
stage: deploy
needs:
- build-job
before_script:
- SERVICE=$(echo "$CI_COMMIT_REF_NAME" | sed 's/^\(stage\|prod\)-//' | sed 's/-[0-9.]*$//')
- TAG=$(echo "$CI_COMMIT_REF_NAME" | rev | cut -d '-' -f1 | rev)
- export TAG
- export SERVICE
- pwd
- whoami
- hostname
script:
- docker-compose -H 192.168.1.193:2375 -f /srv/backup/docker-compose.yaml up
environment:
name: stageing
rules:
- if: '$CI_COMMIT_TAG =~ /^prod-/'
when: manual
- when: on_success