Skip to content

CLOUDP-334379/improve-promotion #2552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 8 additions & 37 deletions .github/workflows/promote-image.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,22 @@
name: Promote Image

on:
workflow_run:
workflows: ["Test"]
types: [completed]
workflow_call:

jobs:
# Check-test-status: Uses the hook called test-status on the test.yml job in order to
# see if any test failed or was skipped; promotion should only run when all tests suceeded!
check-test-status:
runs-on: ubuntu-latest
outputs:
test-status: ${{ steps.set-status.outputs.status }}
steps:
- name: Ensure test-status job completed
id: set-status
env:
REPO: ${{ github.repository }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RUN_ID: ${{ github.event.workflow_run.id }}
run: |
jobs=$(gh api --paginate /repos/$REPO/actions/runs/$RUN_ID/jobs --jq '.jobs[] | select(.name == "Final Test Status")')

if [[ -z "$jobs" ]]; then
echo "test-status job not found"
exit 1
fi

conclusion=$(echo "$jobs" | jq -r '.conclusion')
echo "status=$conclusion" >> "$GITHUB_OUTPUT"

# Promote image: this will be responbile for taking a tested image from an unofficial registry like
# Promote image: this will be responsible for taking a tested image from an unofficial registry like
# ghcr.io and promote it by adding it to an official registry (docker.io and quay.io)
promote-image:
runs-on: ubuntu-latest
environment: release
needs: check-test-status
if: |
needs.check-test-status.outputs.test-status == 'success'
env:
GHCR_REPO: ghcr.io/mongodb/mongodb-atlas-kubernetes-operator-prerelease
DOCKER_REPO: docker.io/mongodb/mongodb-atlas-kubernetes-operator-prerelease
QUAY_REPO: quay.io/mongodb/mongodb-atlas-kubernetes-operator-prerelease
steps:
- name: Checkout PR commit
uses: actions/checkout@v4

# Login in all the needed registries
- name: Log in to the GitHub Container Registry
uses: docker/login-action@v3
Expand Down Expand Up @@ -73,9 +44,9 @@ jobs:
id: set_tag
uses: ./.github/actions/set-tag
with:
branch_name: ${{ github.event.workflow_run.head_branch }}
commit_sha: ${{ github.event.workflow_run.head_sha }}
branch_name: ${{ github.ref_name }}
commit_sha: ${{ github.sha }}

- name: Prepare tag for promoted image
id: promoted_tag
run: |
Expand All @@ -91,7 +62,7 @@ jobs:
IMAGE_DEST_REPO: ${{ env.DOCKER_REPO }}
IMAGE_SRC_TAG: ${{ steps.set_tag.outputs.tag }}
IMAGE_DEST_TAG: ${{ steps.promoted_tag.outputs.tag }}
ALIAS_ENABLED: ${{ github.event.workflow_run.head_branch == 'main' }}
ALIAS_ENABLED: ${{ github.ref_name == 'main' }}
ALIAS_TAG: promoted-latest

- name: Move image to Quay
Expand All @@ -101,5 +72,5 @@ jobs:
IMAGE_DEST_REPO: ${{ env.QUAY_REPO }}
IMAGE_SRC_TAG: ${{ steps.set_tag.outputs.tag }}
IMAGE_DEST_TAG: ${{ steps.promoted_tag.outputs.tag }}
ALIAS_ENABLED: ${{ github.event.workflow_run.head_branch == 'main' }}
ALIAS_ENABLED: ${{ github.ref_name == 'main' }}
ALIAS_TAG: promoted-latest
14 changes: 5 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,19 +97,15 @@ jobs:
github.event_name == 'merge_group' || needs.cloud-tests-filter.outputs.run-cloud-tests == 'true'
uses: ./.github/workflows/cloud-tests.yml
secrets: inherit

# Test-status: this is a hook for jobs that require all the tests to succeed like promote-image
# in order to check the overall status of the tests (no test failed nor got skipped)
test-status:
name: Final Test Status

start-promote-image:
name: Start Promote Image
needs:
- lint
- unit-tests
- validate-manifests
- check-licenses
- e2e2
- cloud-tests
runs-on: ubuntu-latest
steps:
- name: All tests status
run: echo "All tests successfully ran. This will get printed only on success!"
uses: ./.github/workflows/promote-image.yml
secrets: inherit
2 changes: 1 addition & 1 deletion docs/dev/ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ Operator images are promoted to official prerelease registries after passing all
- Merges to `main` that modify production code
- Manual dispatch of `tests.yml` with promotion enabled

The [`promote-image.yml`](../../.github/workflows/promote-image.yml) workflow verifies all tests, including cloud-based Helm tests, have passed. If successful, it:
The [`promote-image.yml`](../../.github/workflows/promote-image.yml) workflow runs after all tests, including cloud-based Helm tests, have passed. If successful, it:

- Copies the tested image from `ghcr.io` to `docker.io` and `quay.io`
- Tags the image as `promoted-<commit-sha>` for traceability
Expand Down
3 changes: 1 addition & 2 deletions docs/dev/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,14 @@ During promotion, the operator image used in Helm-based E2E tests is first built

This workflow:

- Verifies that all required tests succeeded
- Moves the image from `ghcr.io` to official prerelease registries in `docker.io` and `quay.io`
- Tags the image in the official prerelease registires as:
- `promoted-<git_sha>` — uniquely maps the image to the source Git commit
- `promoted-latest` — always points to the most recent image that passed all tests

The `promoted-<git_sha>` builds the one-to-one correspondence between the 7-character Git commit and the `image_sha`. For the correspondence between the 7-character Git commit and `image_sha: latest`, we internally store a label within the image `promoted-latest` that has the exact git commit used for that image. Moreover, the `promoted-latest` tag is only updated by events that run on the main branch—whether triggered by a schedule, a merge, or a workflow dispatch. Manual promotions on any other branch will never overwrite this tag.

One can find promoted images by checking the [`promote-image.yml`](../../.github/workflows/promote-image.yml) workflow runs in GitHub Actions, or by browsing the prerelease Docker registries at:
One can find promoted images by browsing the prerelease Docker registries at:

- Docker Hub: `mongodb/mongodb-atlas-kubernetes-prerelease`
- Quay.io: `mongodb/mongodb-atlas-kubernetes-prerelease`
Expand Down
Loading