-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
103 lines (94 loc) · 2.37 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
---
variables:
DOCKERHUB_USER: strowi
include:
- project: 'strowi/ci-templates'
file: '/build.yml'
- project: 'strowi/ci-templates'
file: '/tests.yml'
- project: 'strowi/ci-templates'
file: '/k3d.yml'
stages:
- build
- test
- release
# "build_image" -> "${CI_REGISTRY_IMAGE}"
# "build_image $sub_image ./sub_dir/" -> "${CI_REGISTRY_IMAGE}/sub_name
# always tagged + pushed with:release
# - ":${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHA}"
# - ":${CI_COMMIT_REF_SLUG}"
# - ":latest" (NOT pushed, for building dependent images)
docker:build:
extends: .build
stage: build
script:
- build_image
container_scanning:
extends: .container_scanning
# parallel:
# matrix:
# - SUB_IMAGE_NAME:
# - /xyz
dgoss:test:
extends: .dgoss
script:
- dgoss_run ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA} sleep 5s
# "release_latest" -> "${CI_REGISTRY_IMAGE}"
# "release_latest./sub_dir/" -> "${CI_REGISTRY_IMAGE}/sub_name
# push current "${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHA}" as ":latest"
release_latest:
extends: .build
stage: release
script:
- release_latest
rules:
- if: $CI_COMMIT_TAG
when: never
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
exists:
- Dockerfile
- when: never
# "release_tag" -> "${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}" + docker-hub
release_tag:
extends: .build
stage: release
script:
- release_tag
- release_dockerhub
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: never
- if: $CI_COMMIT_TAG
exists:
- Dockerfile
- when: never
deploy-tests:
stage: test
extends: .k3d
image: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA}
environment: ci
script:
- start_k3d
- deploy-k8
- get_pod nginx-krane
- deploy-helm
- get_pod nginx-helm
- kubectl get deploy,po --all-namespaces
parallel:
matrix:
- K3S_VERSION:
- v1.28.9-k3s1
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
exists:
- Dockerfile
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS
when: never
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
exists:
- Dockerfile
- if: $CI_COMMIT_BRANCH
exists:
- Dockerfile
- if: $CI_COMMIT_TAG
when: never