Skip to content

Commit 4a0bd55

Browse files
committed
ci(pr_test_build_images): Build images and check it is tagged correctly
1 parent 3f91c2b commit 4a0bd55

File tree

1 file changed

+108
-7
lines changed

1 file changed

+108
-7
lines changed

.github/workflows/pr_test_build_images.yaml

Lines changed: 108 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,42 @@ on:
88
# paths: []
99

1010
env:
11+
BASE_BRANCH: ${{ github.base_ref }}
1112
GIT_BASE_REF: ${{ github.event.pull_request.base.sha }}
1213
GIT_HEAD_REF: ${{ github.event.pull_request.head.sha }}
1314

1415
jobs:
16+
# look at the branch that we are merging into:
17+
# main -> 0.0.0-dev
18+
# release-XX.X -> XX.X
19+
# release-XX.X.X -> XX.X.X
20+
# release-XX.X-rcY -> XX.X-rcY
21+
# release-XX.X.X-rcY -> XX.X-rcY
22+
determine_sdp_version:
23+
name: Determine SDP Version
24+
runs-on: ubuntu-latest
25+
steps:
26+
- id: extract_sdp_version
27+
shell: bash
28+
name: sdp_version
29+
run: |
30+
set -euo pipefail
31+
32+
case "$BASE_BRANCH" in
33+
main)
34+
echo "sdp_version=0.0.0-dev" | tee -a "$GITHUB_OUTPUT"
35+
;;
36+
release-*)
37+
echo "sdp_version=${BASE_BRANCH#release-}" | tee -a "$GITHUB_OUTPUT"
38+
;;
39+
*)
40+
>&2 echo "Unexpected branch. Update the workflow branch filter and add a case above"
41+
exit 1
42+
;;
43+
esac
44+
outputs:
45+
sdp_version: ${{ steps.extract_sdp_version.outputs.sdp_version }}
46+
1547
# The set of paths for changed files (eg: airflow/Dockerfile, zookeeper/stackable/jmx/server.yaml)
1648
# ... limited to the product-paths (eg: airflow, zookeeper) that have a versions.py
1749
# Then for each _product_, shard based on product versions that have the "test" indicator
@@ -22,6 +54,7 @@ jobs:
2254
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
2355
with:
2456
fetch-depth: 0
57+
# todo, move this to stackabletech/actions
2558
- id: shard
2659
shell: bash
2760
env:
@@ -49,7 +82,7 @@ jobs:
4982

5083
build:
5184
name: Build/Publish ${{ matrix.product_version_pairs.name }}-${{ matrix.product_version_pairs.version }}-${{ matrix.runner.arch }} Image
52-
needs: [generate_matrix]
85+
needs: [determine_sdp_version, generate_matrix]
5386
permissions:
5487
id-token: write
5588
runs-on: ${{ matrix.runner.name }}
@@ -60,12 +93,80 @@ jobs:
6093
- {name: "ubicloud-standard-8-arm", arch: "arm64"}
6194
# Eg: [{"name":"airflow","version":"2.10.2"},{"name":"airflow","version":"2.9.3"},{"name":"zookeeper","version":"3.9.2"}]
6295
product_version_pairs: ${{ fromJson(needs.generate_matrix.outputs.product_version_pairs) }}
96+
env:
97+
SDP_VERSION: ${{ needs.determine_sdp_version.outputs.sdp_version }}
98+
PRODUCT_NAME: ${{ matrix.product_version_pairs.name }}
99+
PRODUCT_VERSION: ${{ matrix.product_version_pairs.version }}
63100
steps:
64101
- name: Checkout Repository
65102
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
66-
- env:
67-
PRODUCT_NAME: ${{ matrix.product_version_pairs.name }}
68-
PRODUCT_VERSION: ${{ matrix.product_version_pairs.version }}
69-
run: |
70-
echo "PRODUCT_NAME=$PRODUCT_NAME"
71-
echo "PRODUCT_VERSION=$PRODUCT_VERSION"
103+
104+
- name: Free Disk Space
105+
uses: stackabletech/actions/free-disk-space@a3f7587879e9f12e04a29fd26435949aaa4fd59c # 0.2.0
106+
107+
- name: Build Product Image
108+
id: build
109+
uses: stackabletech/actions/build-product-image@a3f7587879e9f12e04a29fd26435949aaa4fd59c # 0.2.0
110+
with:
111+
product-name: ${{ env.PRODUCT_NAME }}
112+
product-version: ${{ env.PRODUCT_VERSION }}
113+
build-cache-password: ${{ secrets.BUILD_CACHE_NEXUS_PASSWORD }}
114+
sdp-version: ${{ env.SDP_VERSION }}+pr${{ github.event.pull_request.number }}
115+
116+
- run: |
117+
docker images
118+
119+
# - name: Publish Container Image on docker.stackable.tech
120+
# uses: stackabletech/actions/publish-image@a3f7587879e9f12e04a29fd26435949aaa4fd59c # 0.2.0
121+
# with:
122+
# image-registry-uri: docker.stackable.tech
123+
# image-registry-username: github
124+
# image-registry-password: ${{ secrets.NEXUS_PASSWORD }}
125+
# image-repository: stackable/${{ env.PRODUCT_NAME }}
126+
# image-manifest-tag: ${{ steps.build.outputs.image-manifest-tag }}
127+
# source-image-uri: localhost/${{ env.PRODUCT_NAME }}:${{ steps.build.outputs.image-manifest-tag }}
128+
129+
# - name: Publish Container Image on oci.stackable.tech
130+
# uses: stackabletech/actions/publish-image@a3f7587879e9f12e04a29fd26435949aaa4fd59c # 0.2.0
131+
# with:
132+
# image-registry-uri: oci.stackable.tech
133+
# image-registry-username: robot$sdp+github-action-build
134+
# image-registry-password: ${{ secrets.HARBOR_ROBOT_SDP_GITHUB_ACTION_BUILD_SECRET }}
135+
# image-repository: sdp/${{ env.PRODUCT_NAME }}
136+
# image-manifest-tag: ${{ steps.build.outputs.image-manifest-tag }}
137+
# source-image-uri: localhost/${{ env.PRODUCT_NAME }}:${{ steps.build.outputs.image-manifest-tag }}
138+
139+
# publish_manifests:
140+
# name: Build/Publish ${{ matrix.product_version_pairs.name }}-${{ matrix.product_version_pairs.version }}-${{ matrix.runner.arch }} Manifests
141+
# needs: [determine_sdp_version, generate_matrix, build]
142+
# permissions:
143+
# id-token: write
144+
# runs-on: ubuntu-latest
145+
# strategy:
146+
# matrix:
147+
# product_version_pairs: ${{ fromJson(needs.generate_matrix.outputs.product_version_pairs) }}
148+
# env:
149+
# SDP_VERSION: ${{ needs.determine_sdp_version.outputs.sdp_version }}
150+
# PRODUCT_NAME: ${{ matrix.product_version_pairs.name }}
151+
# PRODUCT_VERSION: ${{ matrix.product_version_pairs.version }}
152+
# steps:
153+
# - name: Checkout Repository
154+
# uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
155+
156+
# - name: Publish and Sign Image Index Manifest to docker.stackable.tech
157+
# uses: stackabletech/actions/publish-index-manifest@a3f7587879e9f12e04a29fd26435949aaa4fd59c # 0.2.0
158+
# with:
159+
# image-registry-uri: docker.stackable.tech
160+
# image-registry-username: github
161+
# image-registry-password: ${{ secrets.NEXUS_PASSWORD }}
162+
# image-repository: stackable/${{ env.PRODUCT_NAME }}
163+
# image-index-manifest-tag: ${{ env.PRODUCT_VERSION }}-stackable${{ env.SDP_VERSION }}+pr${{ github.event.pull_request.number }}
164+
165+
# - name: Publish and Sign Image Index Manifest to oci.stackable.tech
166+
# uses: stackabletech/actions/publish-index-manifest@a3f7587879e9f12e04a29fd26435949aaa4fd59c # 0.2.0
167+
# with:
168+
# image-registry-uri: oci.stackable.tech
169+
# image-registry-username: robot$sdp+github-action-build
170+
# image-registry-password: ${{ secrets.HARBOR_ROBOT_SDP_GITHUB_ACTION_BUILD_SECRET }}
171+
# image-repository: sdp/${{ env.PRODUCT_NAME }}
172+
# image-index-manifest-tag: ${{ matrix.versions }}-stackable${{ env.SDP_VERSION }}+pr${{ github.event.pull_request.number }}

0 commit comments

Comments
 (0)