Skip to content

Commit 3be4823

Browse files
committed
Migrate pipeline to ghcr.io
1 parent 0fa35d3 commit 3be4823

File tree

3 files changed

+70
-41
lines changed

3 files changed

+70
-41
lines changed

.github/workflows/main.yml

+35-7
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,19 @@ jobs:
2020
with:
2121
install: true
2222

23-
- name: "Docker login"
23+
- name: "Docker login docker.io"
2424
uses: docker/login-action@v3
2525
with:
2626
username: kbstci
2727
password: ${{ secrets.DOCKER_AUTH }}
2828

29+
- name: "Docker login ghcr.io"
30+
uses: docker/login-action@v3
31+
with:
32+
registry: ghcr.io
33+
username: ${{ github.actor }}
34+
password: ${{ secrets.GITHUB_TOKEN }}
35+
2936
- name: "Build artifacts"
3037
env:
3138
DOCKER_PUSH: true
@@ -75,12 +82,19 @@ jobs:
7582
with:
7683
install: true
7784

78-
- name: "Docker login"
85+
- name: "Docker login docker.io"
7986
uses: docker/login-action@v3
8087
with:
8188
username: kbstci
8289
password: ${{ secrets.DOCKER_AUTH }}
8390

91+
- name: "Docker login ghcr.io"
92+
uses: docker/login-action@v3
93+
with:
94+
registry: ghcr.io
95+
username: ${{ github.actor }}
96+
password: ${{ secrets.GITHUB_TOKEN }}
97+
8498
- name: Build ${{ matrix.starter }} image
8599
env:
86100
DOCKER_PUSH: true
@@ -91,7 +105,7 @@ jobs:
91105
env:
92106
COSIGN_EXPERIMENTAL: true
93107
run: |
94-
cosign sign --yes -a GIT_HASH=${{ github.sha }} -a GIT_REF=${{ github.ref }} kubestack/framework-dev:test-${{ github.sha }}-${{ matrix.starter }}
108+
cosign sign --yes -a GIT_HASH=${{ github.sha }} -a GIT_REF=${{ github.ref }} ghcr.io/kbst/terraform-kubestack/dev:test-${{ github.sha }}-${{ matrix.starter }}
95109
96110
test:
97111
runs-on: ubuntu-latest
@@ -112,12 +126,19 @@ jobs:
112126
run: |
113127
unzip quickstart/_dist/kubestack-starter-${{ matrix.starter }}-*.zip
114128
115-
- name: "Docker login"
129+
- name: "Docker login docker.io"
116130
uses: docker/login-action@v3
117131
with:
118132
username: kbstci
119133
password: ${{ secrets.DOCKER_AUTH }}
120134

135+
- name: "Docker login ghcr.io"
136+
uses: docker/login-action@v3
137+
with:
138+
registry: ghcr.io
139+
username: ${{ github.actor }}
140+
password: ${{ secrets.GITHUB_TOKEN }}
141+
121142
- name: "Docker build"
122143
env:
123144
DOCKER_BUILDKIT: 1
@@ -126,7 +147,7 @@ jobs:
126147
# to kubestack/framework after they have been tested
127148
# but the Dockerfiles in the artifact have the target image name
128149
run: |
129-
SOURCE_IMAGE=kubestack/framework-dev:test-${{ github.sha }}-${{ matrix.starter }}
150+
SOURCE_IMAGE=ghcr.io/kbst/terraform-kubestack/dev:test-${{ github.sha }}-${{ matrix.starter }}
130151
docker pull $SOURCE_IMAGE
131152
TARGET_IMAGE=$(cat Dockerfile | sed 's/FROM //')
132153
docker tag $SOURCE_IMAGE $TARGET_IMAGE
@@ -217,19 +238,26 @@ jobs:
217238
- name: Install Cosign
218239
uses: sigstore/cosign-installer@9614fae9e5c5eddabb09f90a270fcb487c9f7149 #v3.7.0
219240

220-
- name: "Docker login"
241+
- name: "Docker login docker.io"
221242
uses: docker/login-action@v3
222243
with:
223244
username: kbstci
224245
password: ${{ secrets.DOCKER_AUTH }}
225246

247+
- name: "Docker login ghcr.io"
248+
uses: docker/login-action@v3
249+
with:
250+
registry: ghcr.io
251+
username: ${{ github.actor }}
252+
password: ${{ secrets.GITHUB_TOKEN }}
253+
226254
- name: "Docker push"
227255
# cosign copy copies the images and the signature from one place to another
228256
# then we dont need to sign again the same image
229257
env:
230258
COSIGN_EXPERIMENTAL: true
231259
run: |
232-
SOURCE_IMAGE=kubestack/framework-dev:test-${{ github.sha }}-${{ matrix.starter }}
260+
SOURCE_IMAGE=ghcr.io/kbst/terraform-kubestack/dev:test-${{ github.sha }}-${{ matrix.starter }}
233261
TARGET_IMAGE=$(cat quickstart/_dist/kubestack-starter-${{ matrix.starter }}/Dockerfile | sed 's/FROM //')
234262
echo "Source image $SOURCE_IMAGE will be pushed to $TARGET_IMAGE"
235263
cosign copy $SOURCE_IMAGE $TARGET_IMAGE

Makefile

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ DOCKER_TARGET ?= multi-cloud
88

99
ifeq ("${DOCKER_PUSH}", "true")
1010
BUILD_PLATFORM := --platform linux/arm64,linux/amd64
11-
BUILD_CACHE_DIST := --cache-to type=registry,mode=max,ref=kubestack/framework-dev:buildcache-dist-helper,push=${DOCKER_PUSH}
11+
BUILD_CACHE_DIST := --cache-to type=registry,mode=max,ref=ghcr.io/kbst/terraform-kubestack/dev:buildcache-dist-helper,push=${DOCKER_PUSH}
1212
BUILD_OUTPUT := --output type=registry,push=${DOCKER_PUSH}
13-
BUILD_CACHE := --cache-to type=registry,mode=max,ref=kubestack/framework-dev:buildcache-${DOCKER_TARGET},push=${DOCKER_PUSH}
13+
BUILD_CACHE := --cache-to type=registry,mode=max,ref=ghcr.io/kbst/terraform-kubestack/dev:buildcache-${DOCKER_TARGET},push=${DOCKER_PUSH}
1414
else
1515
BUILD_PLATFORM :=
1616
BUILD_OUTPUT := --output type=docker
@@ -24,7 +24,7 @@ dist:
2424
--build-arg GIT_SHA=${GIT_SHA} \
2525
--file oci/Dockerfile \
2626
--output type=docker \
27-
--cache-from type=registry,ref=kubestack/framework-dev:buildcache-dist-helper \
27+
--cache-from type=registry,ref=ghcr.io/kbst/terraform-kubestack/dev:buildcache-dist-helper \
2828
${BUILD_CACHE_DIST} \
2929
--progress plain \
3030
-t dist-helper:latest \
@@ -47,11 +47,11 @@ build:
4747
--build-arg GIT_SHA=${GIT_SHA} \
4848
--file oci/Dockerfile \
4949
${BUILD_OUTPUT} \
50-
--cache-from type=registry,ref=kubestack/framework-dev:buildcache-${DOCKER_TARGET} \
50+
--cache-from type=registry,ref=ghcr.io/kbst/terraform-kubestack/dev:buildcache-${DOCKER_TARGET} \
5151
${BUILD_CACHE} \
5252
--progress plain \
5353
--target ${DOCKER_TARGET} \
54-
-t kubestack/framework-dev:test-$(GIT_SHA)-${DOCKER_TARGET} \
54+
-t ghcr.io/kbst/terraform-kubestack/dev:test-$(GIT_SHA)-${DOCKER_TARGET} \
5555
.
5656

5757
validate: .init
@@ -97,7 +97,7 @@ shell: .check-container
9797
-e KBST_AUTH_GCLOUD \
9898
-e HOME=/infra/tests/.user \
9999
--workdir /infra/tests \
100-
kubestack/framework-dev:test-$(GIT_SHA)-${DOCKER_TARGET} \
100+
ghcr.io/kbst/terraform-kubestack/dev:test-$(GIT_SHA)-${DOCKER_TARGET} \
101101
sleep infinity
102102

103103
.stop-container:

quickstart/build_artifacts/dist.py

+29-28
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,27 @@
77

88
from jinja2 import Environment, FileSystemLoader
99

10-
SRCDIR = '../src'
11-
DISTDIR = '../_dist'
12-
ARTIFACT_PREFIX = 'kubestack-starter-'
10+
SRCDIR = "../src"
11+
DISTDIR = "../_dist"
12+
ARTIFACT_PREFIX = "kubestack-starter-"
1313

1414

1515
def replace_template(dist_path, file_name, context):
1616
jinja = Environment(loader=FileSystemLoader(dist_path))
1717
template = jinja.get_template(file_name)
1818
data = template.render(context)
1919

20-
with open(f'{dist_path}/{file_name}', 'w') as f:
20+
with open(f"{dist_path}/{file_name}", "w") as f:
2121
f.write(data)
2222
# always include newline at end of file
23-
f.write('\n')
23+
f.write("\n")
2424

2525

2626
def dist(version, image_name, configuration):
27-
configuration_src = f'{SRCDIR}/configurations/{configuration}'
28-
configuration_dist = f'{DISTDIR}/{ARTIFACT_PREFIX}{configuration}'
29-
manifests_src = f'{SRCDIR}/manifests'
30-
manifests_dist = f'{configuration_dist}/manifests'
27+
configuration_src = f"{SRCDIR}/configurations/{configuration}"
28+
configuration_dist = f"{DISTDIR}/{ARTIFACT_PREFIX}{configuration}"
29+
manifests_src = f"{SRCDIR}/manifests"
30+
manifests_dist = f"{configuration_dist}/manifests"
3131

3232
# Clean DISTDIR
3333
if isdir(configuration_dist):
@@ -38,46 +38,47 @@ def dist(version, image_name, configuration):
3838
copytree(manifests_src, manifests_dist)
3939

4040
# Replace templated version variables in *.tf files
41-
for tf_file in [n for n in listdir(configuration_dist)
42-
if n.endswith('.tf')]:
43-
replace_template(configuration_dist, tf_file,
44-
{'version': version})
41+
for tf_file in [n for n in listdir(configuration_dist) if n.endswith(".tf")]:
42+
replace_template(configuration_dist, tf_file, {"version": version})
4543

4644
# Replace templated variables in Dockerfiles
47-
dockerfiles = ['Dockerfile', 'Dockerfile.loc']
45+
dockerfiles = ["Dockerfile", "Dockerfile.loc"]
4846
for dockerfile in dockerfiles:
4947
if exists(join(configuration_dist, dockerfile)):
50-
replace_template(configuration_dist,
51-
dockerfile,
52-
{'image_name': image_name, 'image_tag': version})
48+
replace_template(
49+
configuration_dist,
50+
dockerfile,
51+
{"image_name": image_name, "image_tag": version},
52+
)
5353

5454

5555
def compress(version, configuration):
56-
starter = f'{ARTIFACT_PREFIX}{configuration}'
57-
archive = f'{DISTDIR}/{starter}-{version}'
58-
make_archive(archive, 'zip', DISTDIR, starter)
56+
starter = f"{ARTIFACT_PREFIX}{configuration}"
57+
archive = f"{DISTDIR}/{starter}-{version}"
58+
make_archive(archive, "zip", DISTDIR, starter)
5959

6060

6161
if __name__ == "__main__":
6262
# Use tag as version, fallback to commit sha
63-
version = environ.get('GIT_SHA')
63+
version = environ.get("GIT_SHA")
6464
# Non tagged images go to a different image repository
65-
image_name = 'kubestack/framework-dev'
65+
image_name = "ghcr.io/kbst/terraform-kubestack/dev"
6666

67-
gitref = environ.get('GIT_REF')
68-
if gitref.startswith('refs/tags/'):
69-
version = gitref.replace('refs/tags/', '')
67+
gitref = environ.get("GIT_REF")
68+
if gitref.startswith("refs/tags/"):
69+
version = gitref.replace("refs/tags/", "")
7070
# Tagged releases go to main image repository
71-
image_name = 'kubestack/framework'
71+
image_name = "kubestack/framework"
7272

7373
try:
7474
target = argv[1]
7575
except IndexError:
7676
print("positional arg: 'target' missing:")
7777
exit("usage dist.py [dist | compress]")
7878

79-
configurations = [n for n in listdir(f'{SRCDIR}/configurations')
80-
if not n.startswith('_')]
79+
configurations = [
80+
n for n in listdir(f"{SRCDIR}/configurations") if not n.startswith("_")
81+
]
8182

8283
if target not in ["dist", "compress"]:
8384
exit("usage dist.py [dist | compress]")

0 commit comments

Comments
 (0)