-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
63 lines (56 loc) · 1.45 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
# Official framework image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/node/tags/
image: node:lts-alpine
# Pick zero or more services to be used on all builds.
# Only needed when using a docker container to run your tests in.
# Check out: https://docs.gitlab.com/ee/ci/services/index.html
# services:
# - mysql:latest
# - redis:latest
# - postgres:latest
# This folder is cached between builds
# https://docs.gitlab.com/ee/ci/yaml/index.html#cache
workflow:
rules:
- if: $CI_COMMIT_BRANCH != "master" && $CI_PIPELINE_SOURCE != "merge_request_event"
when: never
- when: always
cache:
key: "$CI_COMMIT_REF_NAME"
paths:
- node_modules/
variables:
IMAGE_NAME: imagine-ui
build:
stage: build
tags:
- shell
- linux
only:
- master
before_script:
- export APP_VERSION=$(cat package.json | jq -r .version)
- echo "Image tag version is $APP_VERSION"
# - export APP_VERSION=$APP_VERSION-$CI_PIPELINE_IID
- echo "VERSION=$APP_VERSION" >> build.env
script:
- echo "Building and tagging docker image $IMAGE_NAME:$APP_VERSION"
- docker build -t $IMAGE_NAME:$APP_VERSION .
artifacts:
reports:
dotenv: build.env
deploy:
stage: deploy
tags:
- shell
- linux
only:
- master
needs:
- build
before_script:
- export DC_IMAGE_NAME=$IMAGE_NAME
- export DC_IMAGE_TAG=$VERSION
script:
- docker compose down &&
docker compose up -d