-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
109 lines (95 loc) · 2.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
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
104
105
106
107
108
109
image: golang:1.20
stages:
- test
- build
- publish
gitguardianscan:
image: gitguardian/ggshield:v1.13.5@sha256:82b46a5ebda17645a8aabd3d20cfb65cd65938db4fb6d31275bc91132ff21472
stage: test
script: ggshield secret scan ci
rules:
- if: '$CI_COMMIT_REF_PROTECTED == "true"'
gotest:
stage: test
image: golang:1.20
script:
- go test -v ./...
.docker:build:
stage: build
needs: []
dependencies: []
image:
name: gcr.io/kaniko-project/executor:v1.9.1-debug@sha256:ac169723b2076f9d5804f4bc05c98397e286da6fdcdd5a09fdc179f06ccb3be1
entrypoint: [""]
script:
- /kaniko/executor
--cleanup
--no-push
--context $CI_PROJECT_DIR
--dockerfile $CI_PROJECT_DIR/Dockerfile
--destination $IMAGE_TAG
--tarPath image.tar
artifacts:
paths:
- image.tar
when: on_success
docker:build:tag:
extends: .docker:build
variables:
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
only:
- tags
docker:build:main:
extends: .docker:build
variables:
IMAGE_TAG: $CI_REGISTRY_IMAGE:unstable
NEXT_PUBLIC_ENVIRONMENT: development
only:
- main
#.trivy:scan:
# stage: scan
# image: aquasec/trivy
# script:
# - trivy image --exit-code 1 --severity CRITICAL --no-progress --input image.tar
#trivy:scan:main:
# extends: .trivy:scan
# variables:
# IMAGE_TAG: $CI_REGISTRY_IMAGE:unstable
# only:
# - main
#trivy:scan:tag:
# extends: .trivy:scan
# variables:
# IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
# only:
# - tags
.docker:push:
stage: publish
image:
name: gcr.io/go-containerregistry/crane:debug
entrypoint: [""]
script:
- crane auth login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- crane push image.tar $IMAGE_TAG
docker:push:tag:
extends: .docker:push
needs: [gitguardianscan, gotest, docker:build:tag]
dependencies:
- gitguardianscan
- gotest
- docker:build:tag
variables:
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
only:
- tags
docker:push:main:
extends: .docker:push
needs: [gitguardianscan, gotest, docker:build:main]
dependencies:
- gitguardianscan
- gotest
- docker:build:main
variables:
IMAGE_TAG: $CI_REGISTRY_IMAGE:unstable
only:
- main