-
Notifications
You must be signed in to change notification settings - Fork 12
/
.gitlab-ci.yml
58 lines (55 loc) · 1.38 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
variables:
GRADLE_OPTS: "-Dorg.gradle.daemon=false"
stages:
- build
- package
artifact-build:
image: gradle:7-jdk11
stage: build
script: ./gradlew app:build docs:fatJar
cache:
key: "$CI_COMMIT_REF_NAME"
policy: push
paths:
- app/build/distributions
- docs/build/libs
- .gradle
artifacts:
paths:
- app/build/distributions
- app/Dockerfile
- docs/build/libs
- docs/Dockerfile
expire_in: 1 week
docker-package:
image: docker:latest
stage: package
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- |
if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then
tag=""
echo "Running on default branch '$CI_DEFAULT_BRANCH': tag = 'latest'"
else
tag=":$CI_COMMIT_REF_SLUG"
echo "Running on branch '$CI_COMMIT_BRANCH': tag = $tag"
fi
- |
cd app
docker build --pull -t "${CI_REGISTRY_IMAGE}-app${tag}" .
docker push "${CI_REGISTRY_IMAGE}-app${tag}"
cd ..
- |
cd docs
docker build --pull -t "${CI_REGISTRY_IMAGE}-docs${tag}" .
docker push "${CI_REGISTRY_IMAGE}-docs${tag}"
cd ..
# Run this job in a branch where a Dockerfile exists
rules:
- if: $CI_COMMIT_BRANCH
exists:
- app/Dockerfile
- docs/Dockerfile