Newer
Older
image: gitlab.jonasled.de/jonasled/buildx-docker:latest
stage: build
services:
- docker:dind
before_script:
- docker context create build
- docker buildx create build --use
- docker run --privileged --rm tonistiigi/binfmt --install all
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
- apk add jq
# Default branch leaves tagempty (= latest tag)
# All other branches are tagged with the escaped branch name (commit ref slug)
script:
- |
if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then
tag="latest"
else
tag="$CI_COMMIT_REF_SLUG"
fi
- docker buildx build --platform linux/arm64,linux/amd64 --push --provenance false --tag "$CI_REGISTRY_IMAGE:${tag}" .
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
- export IMAGE_HASH=$(docker buildx imagetools inspect "$CI_REGISTRY_IMAGE:${tag}" --format "{{json .Manifest}}" | jq .digest)
- "echo \"Image Hash: $IMAGE_HASH\""
- echo "$IMAGE_HASH" >> image-hash.txt
artifacts:
paths:
- image-hash.txt
Helm:
stage: bundle
image: alpine:latest
dependencies:
- Docker
before_script:
- apk add curl bash openssl git
- curl -L https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
script:
- helm repo update
- helm dependency update website
- IMAGE_HASH=$(cat image-hash.txt)
- "export NEXT_PATCH_VERSION=\"$(cat website/Chart.yaml | grep ^version: | cut -d ' ' -f 2 | awk -F. '{print $1 \".\" $2 \".\" $3+1}')\""
- "export GIT_SHORT_COMMIT=\"$(git rev-parse --short HEAD)\""
- "sed -i \"s/^ digest: .*/ digest: $IMAGE_HASH/\" website/values.yaml"
- helm package website --version "${NEXT_PATCH_VERSION}-rc-${GIT_SHORT_COMMIT}"
artifacts:
paths:
- text2img-*.tgz
Deploy Helm:
image: curlimages/curl:latest
stage: deploy
script:
- HELM_TGZ=$(ls text2img-*.tgz)
- 'curl --request POST --user gitlab-ci-token:$CI_JOB_TOKEN --form "chart=@${HELM_TGZ}" "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/helm/api/${CI_COMMIT_BRANCH}/charts"'
dependencies:
- Helm