Skip to content

Commit 22545ef

Browse files
Generated commit to update templated files based on rev 09cb1e7 in stackabletech/operator-templating repo. (#271)
Triggered by: Manual run triggered by: dervoeti with message [Push artifacts to Harbor]
1 parent 5062a99 commit 22545ef

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
name: Normal issue
3+
about: This is just a normal empty issue with a simple checklist
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
## Issue checklist
11+
12+
This is a simple checklist of things to bear in mind when creating a new issue.
13+
14+
- [ ] Describe the use-case, as far is possible. For instance, using the pattern "As a XXXX, I would like XXXX to be able to do XXXX" helps to identify the feature as well as the problem it is intended to address.
15+
- [ ] Indicate an approximate level of importance and urgency.
16+
- [ ] Indicate if there is a known work-around until such time as the issue has been implemented.

.github/workflows/build.yml

+2
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,8 @@ jobs:
292292
env:
293293
NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }}
294294
HELM_REPO: ${{ needs.select_helm_repo.outputs.helm_repository }}
295+
OCI_REGISTRY_PASSWORD: ${{ secrets.HARBOR_ROBOT_STACKABLE_GITHUB_ACTION_BUILD_SECRET }}
296+
OCI_REGISTRY_USERNAME: "robot$stackable+github-action-build"
295297
if: needs.select_helm_repo.outputs.helm_repository != 'skip'
296298
outputs:
297299
IMAGE_TAG: ${{ steps.printtag.outputs.IMAGE_TAG }}

Makefile

+36
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@ VERSION := $(shell cargo metadata --format-version 1 | jq -r '.packages[] | sele
1515

1616
DOCKER_REPO := docker.stackable.tech
1717
ORGANIZATION := stackable
18+
OCI_REGISTRY_HOSTNAME := oci.stackable.tech
19+
OCI_REGISTRY_PROJECT_IMAGES := ${ORGANIZATION}/images
20+
OCI_REGISTRY_PROJECT_CHARTS := ${ORGANIZATION}/charts
1821
# this will be overwritten by an environmental variable if called from the github action
1922
HELM_REPO := https://repo.stackable.tech/repository/helm-dev
23+
HELM_CHART_NAME := ${OPERATOR_NAME}
2024
HELM_CHART_ARTIFACT := target/helm/${OPERATOR_NAME}-${VERSION}.tgz
2125

2226
SHELL=/usr/bin/env bash -euo pipefail
@@ -27,8 +31,10 @@ render-readme:
2731
## Docker related targets
2832
docker-build:
2933
docker build --force-rm --build-arg VERSION=${VERSION} -t "${DOCKER_REPO}/${ORGANIZATION}/${OPERATOR_NAME}:${VERSION}" -f docker/Dockerfile .
34+
docker tag "${DOCKER_REPO}/${ORGANIZATION}/${OPERATOR_NAME}:${VERSION}" "${OCI_REGISTRY_HOSTNAME}/${OCI_REGISTRY_PROJECT_IMAGES}/${OPERATOR_NAME}:${VERSION}"
3035

3136
docker-publish:
37+
# push to Nexus
3238
echo "${NEXUS_PASSWORD}" | docker login --username github --password-stdin "${DOCKER_REPO}"
3339
DOCKER_OUTPUT=$$(docker push --all-tags "${DOCKER_REPO}/${ORGANIZATION}/${OPERATOR_NAME}");\
3440
# Obtain the digest of the pushed image from the output of `docker push`, because signing by tag is deprecated and will be removed from cosign in the future\
@@ -41,15 +47,44 @@ docker-publish:
4147
# Uses the keyless signing flow with Github Actions as identity provider\
4248
cosign sign -y ${DOCKER_REPO}/${ORGANIZATION}/${OPERATOR_NAME}:@$$REPO_DIGEST_OF_IMAGE
4349

50+
# push to Harbor
51+
# we need to use "value" here to prevent the variable from being recursively expanded by make (username contains a dollar sign, since it's a Harbor bot)
52+
docker login --username '${value OCI_REGISTRY_USERNAME}' --password '${OCI_REGISTRY_PASSWORD}' '${OCI_REGISTRY_HOSTNAME}'
53+
DOCKER_OUTPUT=$$(docker push --all-tags '${OCI_REGISTRY_HOSTNAME}/${OCI_REGISTRY_PROJECT_IMAGES}/${OPERATOR_NAME}');\
54+
# Obtain the digest of the pushed image from the output of `docker push`, because signing by tag is deprecated and will be removed from cosign in the future\
55+
REPO_DIGEST_OF_IMAGE=$$(echo "$$DOCKER_OUTPUT" | awk '/^${VERSION}: digest: sha256:[0-9a-f]{64} size: [0-9]+$$/ { print $$3 }');\
56+
if [ -z "$$REPO_DIGEST_OF_IMAGE" ]; then\
57+
echo 'Could not find repo digest for container image: ${DOCKER_REPO}/${ORGANIZATION}/${OPERATOR_NAME}:${VERSION}';\
58+
exit 1;\
59+
fi;\
60+
# This generates a signature and publishes it to the registry, next to the image\
61+
# Uses the keyless signing flow with Github Actions as identity provider\
62+
cosign sign -y ${OCI_REGISTRY_HOSTNAME}/${OCI_REGISTRY_PROJECT_IMAGES}/${OPERATOR_NAME}:@$$REPO_DIGEST_OF_IMAGE
63+
4464
# TODO remove if not used/needed
4565
docker: docker-build docker-publish
4666

4767
print-docker-tag:
4868
@echo "${DOCKER_REPO}/${ORGANIZATION}/${OPERATOR_NAME}:${VERSION}"
4969

5070
helm-publish:
71+
# push to Nexus
5172
curl --fail -u "github:${NEXUS_PASSWORD}" --upload-file "${HELM_CHART_ARTIFACT}" "${HELM_REPO}/"
5273

74+
# push to Harbor
75+
# we need to use "value" here to prevent the variable from being recursively expanded by make (username contains a dollar sign, since it's a Harbor bot)
76+
helm registry login --username '${value OCI_REGISTRY_USERNAME}' --password '${OCI_REGISTRY_PASSWORD}' '${OCI_REGISTRY_HOSTNAME}'
77+
# Obtain the digest of the pushed artifact from the output of `helm push`, because signing by tag is deprecated and will be removed from cosign in the future\
78+
HELM_OUTPUT=$$(helm push '${HELM_CHART_ARTIFACT}' 'oci://${OCI_REGISTRY_HOSTNAME}/${OCI_REGISTRY_PROJECT_CHARTS}' 2>&1);\
79+
REPO_DIGEST_OF_ARTIFACT=$$(echo "$$HELM_OUTPUT" | awk '/^Digest: sha256:[0-9a-f]{64}$$/ { print $$2 }');\
80+
if [ -z "$$REPO_DIGEST_OF_ARTIFACT" ]; then\
81+
echo 'Could not find repo digest for helm chart: ${HELM_CHART_NAME}';\
82+
exit 1;\
83+
fi;\
84+
# This generates a signature and publishes it to the registry, next to the chart artifact\
85+
# Uses the keyless signing flow with Github Actions as identity provider\
86+
cosign sign -y ${OCI_REGISTRY_HOSTNAME}/${OCI_REGISTRY_PROJECT_CHARTS}/${HELM_CHART_NAME}:@$$REPO_DIGEST_OF_ARTIFACT
87+
5388
helm-package:
5489
mkdir -p target/helm && helm package --destination target/helm deploy/helm/${OPERATOR_NAME}
5590

@@ -80,6 +115,7 @@ chart-lint: compile-chart
80115
clean: chart-clean
81116
cargo clean
82117
docker rmi --force "${DOCKER_REPO}/${ORGANIZATION}/${OPERATOR_NAME}:${VERSION}"
118+
docker rmi --force '${OCI_REGISTRY_HOSTNAME}/${OCI_REGISTRY_PROJECT_IMAGES}/${OPERATOR_NAME}:${VERSION}'
83119

84120
regenerate-charts: chart-clean compile-chart
85121

0 commit comments

Comments
 (0)