-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
75 lines (70 loc) · 2.21 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
71
72
73
74
75
variables:
DOCKER_IMAGE_TAG: $CI_PIPELINE_IID
DOCKER_IMAGE_NAME: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG
stages:
- build
- deploy
build:image:dev:
stage: build
tags:
- shell-build-runer
rules:
- if: $CI_COMMIT_REF_NAME == "dev" && $CI_PIPELINE_SOURCE != "merge_request_event"
when: on_success
- when: never
before_script:
- docker login -u $CI_REGISTRY_USER_MAIN -p $CI_ACCESS_TOKEN $CI_REGISTRY
script:
- cp $ENV_FILE ./.env
- docker build -t $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG .
- docker push $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG
deploy:image:dev:
stage: deploy
tags:
- shell-runer
variables:
PROJ: pepeunit-frontend-dev
rules:
- if: $CI_COMMIT_REF_NAME == "dev" && $CI_PIPELINE_SOURCE != "merge_request_event"
when: on_success
- when: never
before_script:
- docker login -u $CI_REGISTRY_USER_MAIN -p $CI_ACCESS_TOKEN $CI_REGISTRY
script:
- docker pull $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG
- docker stop $PROJ || echo $?
- docker rm $PROJ || echo $?
- docker run -d --name=$PROJ -p 5501:80 --restart=always $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG
- docker system prune -a -f
build:image:release:
stage: build
tags:
- shell-build-runer
rules:
- if: $CI_COMMIT_REF_NAME == "release" && $CI_PIPELINE_SOURCE != "merge_request_event"
when: on_success
- when: never
before_script:
- docker login -u $CI_REGISTRY_USER_MAIN -p $CI_ACCESS_TOKEN $CI_REGISTRY
script:
- cp $ENV_FILE_RELEASE ./.env
- docker build -t $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG .
- docker push $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG
deploy:image:release:
stage: deploy
tags:
- shell-runer
variables:
PROJ: pepeunit-frontend-release
rules:
- if: $CI_COMMIT_REF_NAME == "release" && $CI_PIPELINE_SOURCE != "merge_request_event"
when: on_success
- when: never
before_script:
- docker login -u $CI_REGISTRY_USER_MAIN -p $CI_ACCESS_TOKEN $CI_REGISTRY
script:
- docker pull $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG
- docker stop $PROJ || echo $?
- docker rm $PROJ || echo $?
- docker run -d --name=$PROJ -p 5502:80 --restart=always $DOCKER_IMAGE_NAME:$DOCKER_IMAGE_TAG
- docker system prune -a -f