-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
71 lines (67 loc) · 2.14 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
include:
- remote: https://gitlab.com/jitesoft/gitlab-ci-lib/raw/master/Scan/trivy.yml
- local: /.gitlab/shared.yml
- local: /.gitlab/stable.yml
- local: /.gitlab/latest.yml
stages:
- check
- download
- build
- containerize
- scan
- create-cache
check-versions:
rules:
- if: '$CI_PIPELINE_SOURCE == "push"'
when: always
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: always
- if: '$CI_PIPELINE_SOURCE == "web"'
when: always
- if: '$CI_PIPELINE_SOURCE == "trigger"'
when: never
stage: check
cache:
key: smallstep-cli-versions
paths:
- latest.txt
- stable.txt
policy: pull
script:
- apk add --no-cache jq wget curl
- STABLE=$(wget -qO- https://api.github.com/repos/smallstep/cli/releases | jq -r ".[0].tag_name")
- LATEST=$(wget -qO- https://api.github.com/repos/smallstep/cli/tags | jq -r ".[0].name")
- touch stable.txt
- touch latest.txt
- echo "Checking if latest (${LATEST} | $(cat latest.txt)) version should be built."
- |
if [ "$(cat latest.txt)" != "${LATEST}" ]; then
echo "Latest should be built."
curl -F token=${CI_JOB_TOKEN} -F ref=master -F "variables[VERSION]=${LATEST}" -F "variables[BUILD]=latest" https://gitlab.com/api/v4/projects/19566024/trigger/pipeline
fi
- echo "Checking if the stable (${STABLE} | $(cat stable.txt)) version should be built."
- |
if [ "$(cat stable.txt)" != "${STABLE}" ]; then
echo "Stable should be built."
curl -F token=${CI_JOB_TOKEN} -F "variables[VERSION]=${STABLE}" -F "variables[BUILD]=stable" -F ref=master https://gitlab.com/api/v4/projects/19566024/trigger/pipeline
fi
- echo "Pipeline triggers have been invoked. This job is done!"
create-cache:
variables:
GIT_STRATEGY: none
stage: create-cache
image: registry.gitlab.com/jitesoft/dockerfiles/alpine:latest
rules:
- if: '$CACHE_CREATE'
when: always
- when: never
script:
- touch stable.txt
- touch latest.txt
- echo "${VERSION}" > ${TYPE}.txt
cache:
paths:
- latest.txt
- stable.txt
key: smallstep-cli-versions
policy: pull-push