forked from hoffic-cz/portfolio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
67 lines (62 loc) · 1.6 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
stages:
- build
- sonarcloud-check
- release
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
variables:
CONTAINER_TEST_IMAGE: $CI_REGISTRY_IMAGE/test:$CI_COMMIT_SHORT_SHA
CONTAINER_RELEASE_IMAGE: $CI_REGISTRY_IMAGE/release:latest
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
build:
stage: build
image: docker:19.03.5
services:
- docker:19.03.5-dind
timeout: 10 minutes
artifacts:
paths:
- ./var/coverage/
expire_in: 30 days
script:
- docker build --pull
--file="./ops/docker/app/Dockerfile"
--tag="$CONTAINER_TEST_IMAGE"
--target=prod
./
- docker create -it --name dummy $CONTAINER_TEST_IMAGE sh
- mkdir -p ./var/
- docker cp dummy:/var/www/html/var/coverage/ ./var/
- docker rm -f dummy
- docker push $CONTAINER_TEST_IMAGE
sonarcloud-check:
stage: sonarcloud-check
image:
name: sonarsource/sonar-scanner-cli:latest
entrypoint: [""]
timeout: 10 minutes
dependencies:
- build
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
before_script:
- mkdir -p .sonar/cache
script:
- sonar-scanner
only:
- master
release:
stage: release
image: docker:19.03.5
services:
- docker:19.03.5-dind
timeout: 5 minutes
only:
- master
script:
- docker pull $CONTAINER_TEST_IMAGE
- docker tag $CONTAINER_TEST_IMAGE $CONTAINER_RELEASE_IMAGE
- docker push $CONTAINER_RELEASE_IMAGE