Skip to content

Commit e241659

Browse files
committed
test: include label inside promotion step
1 parent 99511cc commit e241659

File tree

7 files changed

+267
-38
lines changed

7 files changed

+267
-38
lines changed

.github/actions/build-push-image/action.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,5 @@ runs:
100100
sbom: true
101101
push: true
102102
tags: ${{ inputs.tags }}
103+
labels: |
104+
org.opencontainers.image.revision=${{ github.sha }}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: image2commit
2+
description: Resolve full commit SHA from a promoted image tag.
3+
4+
inputs:
5+
register:
6+
description: "Registry (e.g., docker.io, quay.io)"
7+
required: true
8+
repo:
9+
description: "Repository path (e.g., andrpac/my-repo)"
10+
required: true
11+
image_sha:
12+
description: "Short SHA or 'latest'"
13+
required: true
14+
15+
outputs:
16+
commit_sha:
17+
description: "Resolved full commit SHA"
18+
19+
runs:
20+
using: "composite"
21+
steps:
22+
- name: Install skopeo and jq
23+
shell: bash
24+
run: |
25+
sudo apt-get update
26+
sudo apt-get install -y skopeo jq
27+
28+
- name: Resolve commit SHA
29+
id: resolve
30+
shell: bash
31+
run: |
32+
chmod +x ${{ github.action_path }}/entrypoint.sh
33+
full_sha=$(${{
34+
github.action_path
35+
}}/entrypoint.sh \
36+
"${{ inputs.register }}" \
37+
"${{ inputs.repo }}" \
38+
"${{ inputs.image_sha }}"
39+
)
40+
echo "commit_sha=$full_sha" >> $GITHUB_OUTPUT
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
# Copyright 2025 MongoDB Inc
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# This script retrives the git commit sha given an image sha
17+
18+
set -euo pipefail
19+
20+
registry="$1"
21+
repo="$2"
22+
image_sha="$3"
23+
24+
if [[ "$image_sha" == "latest" ]]; then
25+
tag="promoted-latest"
26+
else
27+
tag="promoted-${image_sha}"
28+
fi
29+
30+
full_image="${registry}/${repo}:${tag}"
31+
32+
sha=$(skopeo inspect "docker://${full_image}" | jq -r '.Labels["org.opencontainers.image.revision"]')
33+
34+
if [[ -z "$sha" || "$sha" == "null" ]]; then
35+
echo "Error: Could not extract commit SHA from $full_image" >&2
36+
exit 1
37+
fi
38+
39+
echo "$sha"

.github/workflows/promote-image.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,6 @@ jobs:
4242
username: ${{ secrets.QUAY_USERNAME }}
4343
password: ${{ secrets.QUAY_PASSWORD }}
4444

45-
# Note, we have to be careful how we retrive the image. The event that pushed
46-
# the image to the ghcr.io repo was mainly a push/schedule that passed all the
47-
# tests. This event has access to github.ref_name. However, the workflow_run
48-
# event does not have access github.ref_name set up.
49-
#
50-
# Therefore, we need to manually specify the branch as main
5145
- name: Prepare image tag
5246
id: set_tag
5347
uses: ./.github/actions/set-tag
@@ -69,6 +63,8 @@ jobs:
6963
IMAGE_DEST_REPO: ${{ env.DOCKER_REPO }}
7064
IMAGE_SRC_TAG: ${{ steps.set_tag.outputs.tag }}
7165
IMAGE_DEST_TAG: ${{ steps.promoted_tag.outputs.tag }}
66+
ALIAS_ENABLED: true
67+
ALIAS_TAG: promoted-latest
7268

7369
- name: Move image to Quay
7470
run: ./scripts/move-image.sh
@@ -77,3 +73,5 @@ jobs:
7773
IMAGE_DEST_REPO: ${{ env.QUAY_REPO }}
7874
IMAGE_SRC_TAG: ${{ steps.set_tag.outputs.tag }}
7975
IMAGE_DEST_TAG: ${{ steps.promoted_tag.outputs.tag }}
76+
ALIAS_ENABLED: true
77+
ALIAS_TAG: promoted-latest

.github/workflows/release-image.yml

Lines changed: 135 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,156 @@ on:
44
workflow_dispatch:
55
inputs:
66
version:
7-
description: "Release version (e.g., 1.2.3)"
7+
description: "Release version"
88
required: true
99
type: string
1010
authors:
11-
description: "Comma-separated list of the release authors' emails (e.g. [email protected],[email protected])"
11+
description: "Comma-separated list of author emails"
1212
required: true
1313
type: string
14-
commit_sha:
15-
description: "Commit SHA to use for the image (e.g. 7c2a91 or latest)"
14+
image_sha:
15+
description: "6-digit commit SHA used for the promoted image (e.g. 3e79a3 or 'latest')"
1616
required: false
1717
default: "latest"
1818
type: string
1919

2020
permissions:
2121
contents: write
2222
pull-requests: write
23-
23+
2424
jobs:
25+
26+
# Note, the first step is necessary for getting the exact commit from the passed in image_sha
27+
# This is because, the release-image step should exactly check out that exact commit
28+
image2commit:
29+
name: Resolve Commit SHA from Image
30+
runs-on: ubuntu-latest
31+
outputs:
32+
commit_sha: ${{ steps.resolve.outputs.commit_sha }}
33+
34+
steps:
35+
- name: Log in to Docker registry
36+
uses: docker/login-action@v3
37+
with:
38+
registry: docker.io
39+
username: ${{ secrets.DOCKER_USERNAME }}
40+
password: ${{ secrets.DOCKER_PASSWORD }}
41+
42+
- name: Run image2commit
43+
id: resolve
44+
uses: ./.github/actions/image2commit
45+
with:
46+
register: docker.io
47+
repo: andrpac/mongodb-atlas-kubernetes-operator-prerelease
48+
image_sha: ${{ github.event.inputs.image_sha }}
49+
50+
check-commit:
51+
name: Check resolved commit
52+
runs-on: ubuntu-latest
53+
needs: image2commit
54+
steps:
55+
- name: Echo resolved commit
56+
run: |
57+
echo "Resolved commit: ${{ needs.image2commit.outputs.commit_sha }}"
58+
59+
prepare-environment:
60+
name: Set up Environment Variables
61+
runs-on: ubuntu-latest
62+
if: false
63+
environment: release
64+
65+
outputs:
66+
# Inputs
67+
version: ${{ steps.setup.outputs.version }}
68+
authors: ${{ steps.setup.outputs.authors }}
69+
commit_sha: ${{ steps.setup.outputs.commit_sha }}
70+
71+
# Release related
72+
release_commit: ${{ steps.setup.outputs.release_commit }}
73+
release_branch: ${{ steps.setup.outputs.release_branch }}
74+
75+
# Tags
76+
promoted_tag: ${{ steps.setup.outputs.promoted_tag }}
77+
release_tag: ${{ steps.setup.outputs.release_tag }}
78+
certified_tag: ${{ steps.setup.outputs.certified_tag }}
79+
80+
# Repos
81+
docker_prerelease_repo: ${{ steps.setup.outputs.docker_prerelease_repo }}
82+
docker_release_repo: ${{ steps.setup.outputs.docker_release_repo }}
83+
docker_signature_repo: ${{ steps.setup.outputs.docker_signature_repo }}
84+
quay_prerelease_repo: ${{ steps.setup.outputs.quay_prerelease_repo }}
85+
quay_release_repo: ${{ steps.setup.outputs.quay_release_repo }}
86+
87+
# Image URLs
88+
docker_image_url: ${{ steps.setup.outputs.docker_image_url }}
89+
quay_image_url: ${{ steps.setup.outputs.quay_image_url }}
90+
quay_certified_image_url: ${{ steps.setup.outputs.quay_certified_image_url }}
91+
92+
steps:
93+
- name: Log in to Docker registry
94+
uses: docker/login-action@v3
95+
with:
96+
registry: docker.io
97+
username: ${{ secrets.DOCKER_USERNAME }}
98+
password: ${{ secrets.DOCKER_PASSWORD }}
99+
100+
- name: Resolve inputs
101+
id: inputs
102+
run: |
103+
echo "version=${{ github.event.inputs.version }}" >> $GITHUB_OUTPUT
104+
echo "authors=${{ github.event.inputs.authors }}" >> $GITHUB_OUTPUT
105+
echo "image_sha=${{ github.event.inputs.image_sha }}" >> $GITHUB_OUTPUT
106+
107+
- name: Resolve commit SHA from image
108+
id: image2commit
109+
uses: ./.github/actions/image2commit
110+
with:
111+
image_sha: ${{ steps.inputs.outputs.image_sha }}
112+
repo: docker.io/andrpac/mongodb-atlas-kubernetes-operator-prerelease
113+
114+
- name: Set derived environment variables
115+
id: setup
116+
run: |
117+
version="${{ steps.inputs.outputs.version }}"
118+
authors="${{ steps.inputs.outputs.authors }}"
119+
sha="${{ steps.image2commit.outputs.commit_sha }}"
120+
121+
docker_prerelease_repo="docker.io/andrpac/mongodb-atlas-kubernetes-operator-prerelease"
122+
docker_release_repo="docker.io/andrpac/mongodb-atlas-kubernetes-operator"
123+
docker_signature_repo="docker.io/andrpac/signatures"
124+
quay_prerelease_repo="quay.io/andrpac/mongodb-atlas-kubernetes-operator-prerelease"
125+
quay_release_repo="quay.io/andrpac/mongodb-atlas-kubernetes-operator"
126+
127+
short_sha="${sha:0:6}"
128+
promoted_tag="promoted-${short_sha}"
129+
130+
release_tag="$version"
131+
certified_tag="certified-${version}"
132+
release_branch="new-release/${version}"
133+
docker_image_url="${docker_release_repo}:${release_tag}"
134+
quay_image_url="${quay_release_repo}:${release_tag}"
135+
quay_certified_image_url="${quay_release_repo}:${certified_tag}"
136+
137+
echo "version=$version" >> $GITHUB_OUTPUT
138+
echo "authors=$authors" >> $GITHUB_OUTPUT
139+
echo "commit_sha=${{ steps.inputs.outputs.image_sha }}" >> $GITHUB_OUTPUT
140+
echo "release_commit=$sha" >> $GITHUB_OUTPUT
141+
echo "release_branch=$release_branch" >> $GITHUB_OUTPUT
142+
echo "promoted_tag=$promoted_tag" >> $GITHUB_OUTPUT
143+
echo "release_tag=$release_tag" >> $GITHUB_OUTPUT
144+
echo "certified_tag=$certified_tag" >> $GITHUB_OUTPUT
145+
echo "docker_prerelease_repo=$docker_prerelease_repo" >> $GITHUB_OUTPUT
146+
echo "docker_release_repo=$docker_release_repo" >> $GITHUB_OUTPUT
147+
echo "docker_signature_repo=$docker_signature_repo" >> $GITHUB_OUTPUT
148+
echo "quay_prerelease_repo=$quay_prerelease_repo" >> $GITHUB_OUTPUT
149+
echo "quay_release_repo=$quay_release_repo" >> $GITHUB_OUTPUT
150+
echo "docker_image_url=$docker_image_url" >> $GITHUB_OUTPUT
151+
echo "quay_image_url=$quay_image_url" >> $GITHUB_OUTPUT
152+
echo "quay_certified_image_url=$quay_certified_image_url" >> $GITHUB_OUTPUT
153+
25154
release-image:
26155
runs-on: ubuntu-latest
156+
if: false
27157
environment: release
28158
env:
29159
VERSION: ${{ github.event.inputs.version }}

.github/workflows/test-e2e.yml

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ jobs:
1818
steps:
1919
- uses: actions/checkout@v4
2020

21-
- id: compute
22-
name: Compute K8s Matrix
21+
- name: Compute K8s matrix/versions for testing
22+
id: compute
2323
run: |
2424
matrix='["v1.30.10-kind"]'
2525
if [ "${{ github.ref }}" == "refs/heads/main" ]; then
@@ -37,21 +37,25 @@ jobs:
3737
- uses: actions/checkout@v4
3838
with:
3939
ref: ${{ github.event.pull_request.head.sha || github.sha }}
40-
41-
- id: set_tag
40+
41+
- name: Prepare image tag
42+
id: set_tag
4243
uses: ./.github/actions/set-tag
43-
44-
- id: set_image_url
44+
45+
- name: Prepare image url for GitHub Container Registry
46+
id: set_image_url
4547
run: |
4648
echo "image_url=${REPO}:${{ steps.set_tag.outputs.tag }}" >> "$GITHUB_OUTPUT"
4749
48-
- run: |
49-
echo "${{ secrets.GITHUB_TOKEN }}" \
50-
| docker login ghcr.io \
51-
-u ${{ github.actor }} \
52-
--password-stdin
53-
54-
- uses: ./.github/actions/build-push-image
50+
- name: Log in to the GitHub Container Registry
51+
uses: docker/login-action@v3
52+
with:
53+
registry: ghcr.io
54+
username: ${{ github.actor }}
55+
password: ${{ secrets.GITHUB_TOKEN }}
56+
57+
- name: Build and push image to GitHub Container Registry
58+
uses: ./.github/actions/build-push-image
5559
with:
5660
file: fast.Dockerfile
5761
repository: ${{ env.REPO }}
@@ -75,13 +79,15 @@ jobs:
7579
steps:
7680
- uses: actions/checkout@v4
7781
with:
78-
ref: ${{ github.event.pull_request.head.sha }}
79-
80-
- uses: jetify-com/[email protected]
82+
ref: ${{ github.event.pull_request.head.sha || github.sha }}
83+
84+
- name: Install devbox
85+
uses: jetify-com/[email protected]
8186
with:
8287
enable-cache: 'true'
8388

84-
- uses: ./.github/actions/gen-install-scripts
89+
- name: Generate kustomized all-in-one install configs
90+
uses: ./.github/actions/gen-install-scripts
8591
with:
8692
ENV: dev
8793
VERSION: dev
@@ -92,7 +98,7 @@ jobs:
9298
echo "k8s_version=$(echo '${{ matrix.k8s }}' | awk -F '-' '{print $1}')" >> $GITHUB_OUTPUT
9399
echo "k8s_platform=$(echo '${{ matrix.k8s }}' | awk -F '-' '{print $2}')" >> $GITHUB_OUTPUT
94100
95-
- name: Setup kind cluster if needed
101+
- name: Setup kind cluster
96102
if: ${{ steps.extract.outputs.k8s_platform == 'kind' }}
97103
uses: helm/[email protected]
98104
with:
@@ -102,9 +108,14 @@ jobs:
102108
cluster_name: ${{ matrix.test }}-${{ matrix.k8s }}
103109
wait: 180s
104110

105-
- run: devbox run -- kubectl version
106-
- run: devbox run -- kubectl apply -f deploy/crds
107-
- run: devbox run -- ./scripts/launch-ci-e2e.sh
111+
- name: Print Kubernetes version
112+
run: devbox run -- kubectl version
113+
114+
- name: Apply CRDs
115+
run: devbox run -- kubectl apply -f deploy/crds
116+
117+
- name: Run CI E2E tests
118+
run: devbox run -- ./scripts/launch-ci-e2e.sh
108119
env:
109120
TEST_NAME: ${{ matrix.test }}
110121
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
@@ -118,7 +129,8 @@ jobs:
118129
DATADOG_KEY: ${{ secrets.DATADOG_KEY }}
119130
PAGER_DUTY_SERVICE_KEY: ${{ secrets.PAGER_DUTY_SERVICE_KEY }}
120131

121-
- if: ${{ failure() }}
132+
- name: Upload logs on failure
133+
if: ${{ failure() }}
122134
uses: actions/upload-artifact@v4
123135
with:
124136
name: logs

0 commit comments

Comments
 (0)