-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
69 lines (64 loc) · 1.78 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
stages:
- images
- test
- release
# Prepare Docker access
.kaniko:
before_script:
- echo "{\"auths\":{\"${CI_CONTAINER_REGISTRY}\":{\"auth\":\"$(printf "%s:%s" "${REGISTRY_USER}" "${REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
# static check code in merge requests
# fails when code is not ok - you'll have to explicitly ignore a check if you know what you are doing
static code check:
stage: test
image: devdrops/staticcheck:latest
script:
- staticcheck $CI_PROJECT_DIR/cmd/
- staticcheck $CI_PROJECT_DIR/pkg/exporter/
- staticcheck $CI_PROJECT_DIR/pkg/config/
- staticcheck $CI_PROJECT_DIR/pkg/web/
except:
refs:
- tags
release:
image: harbor.cloudical.net/cci-tools/semantic-release@sha256:3c237539f069b3ed5a863f9d02682ca5844a4c5cb3c1e2629043c33c56b93c6d
stage: release
script:
- semantic-release
rules:
- if: $CI_COMMIT_BRANCH == "main" || $CI_COMMIT_BRANCH == "dev"
when: always
- changes:
paths:
- "CHANGELOG.md"
when: never
# build container
build container:
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
extends: .kaniko
only:
refs:
- tags
script: |
/kaniko/executor \
--context $CI_PROJECT_DIR \
--dockerfile $CI_PROJECT_DIR/docker/Dockerfile.pve \
--destination "$CI_CONTAINER_REGISTRY/$CI_REGISTRY_PROJECT/$CI_PROJECT_NAME:${CI_COMMIT_TAG:-latest}"
# only builds on tag creation
build binary:
image: golang:1.20
stage: release
script:
- CGO_ENABLED=0 go mod download
- CGO_ENABLED=0 go build -o "pveinventory-$CI_COMMIT_TAG" cmd/main.go
only:
- tags
except:
- branches
artifacts:
untracked: false
when: on_success
expire_in: "30 days"
paths:
- ./pveinventory-*