-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
86 lines (77 loc) · 2.88 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
# Project IDs and Project URLs
# This is to keep track of which project id points to which project for downstream triggering
# 1. 17258256 - https://gitlab.com/predictions-technology/ads/docker-dask-tf2/
# 2. 17276346 - https://gitlab.com/airt.ai/infobip/docker-dask-tf2
# 3. 17231350 - https://gitlab.com/airt.ai/mercury/docker-dask-tf2
# 4. 19941057 - https://gitlab.com/airt.ai/zaba/docker-dask-tf2
# 5. 29120234 - https://gitlab.com/airt.ai/airt-service
image: docker:latest
services:
- docker:dind
before_script:
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
stages:
- trivy_scan_repo
- build_image
- check_image
- trigger_downstream
trivy_scan_repo:
stage: trivy_scan_repo
script:
- echo "https://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
- apk update
- apk add trivy
- trivy --version
- sh ./trivy_scan_repo.sh
docker_build_push:
stage: build_image
only:
- main
- dev
script:
- echo "https://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
- apk update
- apk add trivy
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME || true
- docker build --cache-from $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME --build-arg CI_JOB_TOKEN --build-arg UBUNTU_VERSION=20.04 -t $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME .
- if [ $CI_COMMIT_REF_NAME = "main" ]; then docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME $CI_REGISTRY_IMAGE:latest; fi
- version=$(head -n 1 version.txt)
- if [ $CI_COMMIT_REF_NAME = "main" ]; then docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME $CI_REGISTRY_IMAGE:$version; fi
- sh ./check_docker.sh
- docker push $CI_REGISTRY_IMAGE --all-tags
docker_build:
stage: build_image
except:
- main
- dev
script:
- echo "https://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
- apk update
- apk add trivy
- docker pull $CI_REGISTRY_IMAGE:dev || true
- docker build --cache-from $CI_REGISTRY_IMAGE:dev --build-arg CI_JOB_TOKEN --build-arg UBUNTU_VERSION=20.04 -t $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME .
- sh ./check_docker.sh
docker_image_check:
stage: check_image
only:
- main
- dev
script:
- echo "https://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
- apk update
- apk add trivy
- if [[ $CI_COMMIT_REF_NAME == "main" ]]; then TAG=latest ; else TAG=$CI_COMMIT_REF_NAME ; fi;
- docker pull $CI_REGISTRY_IMAGE:$TAG
- sh ./check_docker.sh
trigger_downstream:
image: ubuntu:20.04
stage: trigger_downstream
only:
- main
- dev
before_script:
- apt update
- apt install --assume-yes curl git
script:
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/airt.ai/downstream-trigger.git
- ./downstream-trigger/downstream.sh https://gitlab.com/api/v4/projects/ $CI_JOB_TOKEN $CI_COMMIT_REF_NAME 29120234