-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
96 lines (88 loc) · 3.08 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
image: golang:1.19.4-alpine
stages:
- test
- build
- deploy
go test:
stage: test
script:
- apk add --no-cache git g++ gettext curl
- scripts/fetch-test-binaries.sh
- envsubst < testdata/oci/config.json.sample > testdata/oci/config.json
- envsubst < testdata/oci/oci-profile.yaml.sample > testdata/oci/oci-profile.yaml
- go mod download
- go test -v -cover .
coverage: '/coverage:\s(\d+(?:\.\d+)?%)/'
go lint:
stage: test
script:
- apk add --no-cache git
- go get -u golang.org/x/lint/golint
- golint -set_exit_status
helm lint:
stage: test
image:
name: alpine/helm:3.10.2
entrypoint: [""]
script:
- helm lint deploy/cert-manager-webhook-oci
docker:latest:
stage: build
image: docker:latest
services:
- docker:dind
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -t $CI_REGISTRY_IMAGE:latest .
- docker push $CI_REGISTRY_IMAGE:latest
only:
- master
- tags
docker:tag:
stage: deploy
image: docker:latest
services:
- docker:dind
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker pull $CI_REGISTRY_IMAGE:latest
- docker tag $CI_REGISTRY_IMAGE:latest $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
needs:
- docker:latest
only:
- tags
helm repo:
stage: build
image:
name: alpine/helm:3.10.2
entrypoint: [""]
script:
## below code is required to keep helm packages of previous builds, but it cannot work as long as https://gitlab.com/gitlab-org/gitlab/issues/5813 is not resolved
# - apk add --no-cache jq
# - 'PREVIOUS_TAG_PIPELINE=$(wget -q -O - --header "JOB-TOKEN: $CI_JOB_TOKEN" "https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/pipelines?scope=tags&status=success&order_by=updated_at&sort=desc" | jq ".[0].id")'
# - '[ $PREVIOUS_TAG_PIPELINE != "null" ] && PREVIOUS_TAG_PAGES_JOB=$(wget -q -O - --header "JOB-TOKEN: $CI_JOB_TOKEN" "https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/pipelines/$PREVIOUS_TAG_PIPELINE/jobs?scope=success" | jq ".[] | select(.name="pages") | .id")'
# - '[ $PREVIOUS_TAG_PAGES_JOB != "null" ] && wget --output-document previous-pages.zip --header "JOB-TOKEN: $CI_JOB_TOKEN" "https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/jobs/$PREVIOUS_TAG_PAGES_JOB/artifacts"'
- 'wget --output-document previous-pages.zip --header "JOB-TOKEN: $CI_JOB_TOKEN" "https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/jobs/artifacts/master/download?job=pages" || echo "no previous pages"'
- '[ -f previous-pages.zip ] && unzip -n previous-pages.zip'
- mkdir -p public
- "echo \"User-Agent: *\nDisallow: /\" > public/robots.txt"
- helm package deploy/cert-manager-webhook-oci --destination public
- helm repo index --url https://${CI_PROJECT_NAMESPACE}.gitlab.io/${CI_PROJECT_NAME} public
only:
- master
- tags
artifacts:
paths:
- public
pages:
stage: deploy
artifacts:
paths:
- public
script:
- mkdir -p public
only:
- tags
needs:
- helm repo