Skip to content

Commit 984e926

Browse files
committed
feat: create release pipeline
1 parent 645a0dc commit 984e926

File tree

13 files changed

+382
-127
lines changed

13 files changed

+382
-127
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,3 +99,5 @@ runs:
9999
sbom: true
100100
push: true
101101
tags: ${{ inputs.tags }}
102+
labels: |
103+
org.opencontainers.image.revision=${{ github.sha }}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
value: ${{ steps.resolve.outputs.commit_sha }}
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+
41+
echo "Raw full_sha: $full_sha"
42+
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/cloud-tests-filter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
ACTOR: ${{ github.actor }}
5656
run: |
5757
# Evaluate whether or not cloud tests should run
58-
RUN_CLOUD_TESTS='false'
58+
RUN_CLOUD_TESTS='true'
5959
# Scheduled runs on default branch always run all tests
6060
if [ "${EVENT}" == "schedule" ];then
6161
RUN_CLOUD_TESTS='true'

.github/workflows/cloud-tests.yml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,7 @@ jobs:
2121
- name: allowed message
2222
run: echo "Allowed to run"
2323

24-
int-tests:
25-
needs: allowed
26-
uses: ./.github/workflows/test-int.yml
27-
secrets: inherit
28-
2924
e2e-tests:
3025
needs: allowed
3126
uses: ./.github/workflows/test-e2e.yml
3227
secrets: inherit
33-
34-
test-e2e-gov:
35-
needs:
36-
- allowed
37-
uses: ./.github/workflows/test-e2e-gov.yml
38-
secrets: inherit
39-
40-
openshift-upgrade-test:
41-
needs: allowed
42-
uses: ./.github/workflows/openshift-upgrade-test.yaml
43-
secrets: inherit

.github/workflows/promote-image.yml

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,43 +21,33 @@ jobs:
2121
- name: Checkout PR commit
2222
uses: actions/checkout@v4
2323

24-
# Note, we have to be careful how we retrive the image. The event that pushed
25-
# the image to the ghcr.io repo was mainly a push/schedule that passed all the
26-
# tests. This event has access to github.ref_name. However, the workflow_run
27-
# event does not have access github.ref_name set up.
28-
#
29-
# Therefore, we need to manually specify the branch as main
30-
- name: Prepare image tag
31-
id: set_tag
32-
uses: ./.github/actions/set-tag
33-
with:
34-
branch_name: ${{ github.event.workflow_run.head_branch }}
35-
commit_sha: ${{ github.event.workflow_run.head_sha }}
36-
3724
- name: Log in to the GitHub Container Registry
3825
uses: docker/login-action@v3
3926
with:
4027
registry: ghcr.io
4128
username: ${{ github.actor }}
4229
password: ${{ secrets.GITHUB_TOKEN }}
4330

44-
- name: Pull unofficial image from GitHub Container Registry
45-
run: |
46-
docker pull ${{ env.GHCR_REPO }}:${{ steps.set_tag.outputs.tag }}
47-
4831
- name: Login to Docker registry
4932
uses: docker/login-action@v3
5033
with:
5134
registry: docker.io
5235
username: ${{ secrets.DOCKER_USERNAME }}
5336
password: ${{ secrets.DOCKER_PASSWORD }}
54-
37+
5538
- name: Log in to Quay registry
5639
uses: docker/login-action@v3
5740
with:
5841
registry: quay.io
5942
username: ${{ secrets.QUAY_USERNAME }}
6043
password: ${{ secrets.QUAY_PASSWORD }}
44+
45+
- name: Prepare image tag
46+
id: set_tag
47+
uses: ./.github/actions/set-tag
48+
with:
49+
branch_name: ${{ github.event.workflow_run.head_branch }}
50+
commit_sha: ${{ github.event.workflow_run.head_sha }}
6151

6252
- name: Prepare tag for promoted image
6353
id: promoted_tag
@@ -73,6 +63,8 @@ jobs:
7363
IMAGE_DEST_REPO: ${{ env.DOCKER_REPO }}
7464
IMAGE_SRC_TAG: ${{ steps.set_tag.outputs.tag }}
7565
IMAGE_DEST_TAG: ${{ steps.promoted_tag.outputs.tag }}
66+
ALIAS_ENABLED: true
67+
ALIAS_TAG: promoted-latest
7668

7769
- name: Move image to Quay
7870
run: ./scripts/move-image.sh
@@ -81,3 +73,5 @@ jobs:
8173
IMAGE_DEST_REPO: ${{ env.QUAY_REPO }}
8274
IMAGE_SRC_TAG: ${{ steps.set_tag.outputs.tag }}
8375
IMAGE_DEST_TAG: ${{ steps.promoted_tag.outputs.tag }}
76+
ALIAS_ENABLED: true
77+
ALIAS_TAG: promoted-latest

.github/workflows/release-branch.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# Create Release Branch
1+
# DEPRECATED: Create Release Branch
22
# TODO after GitHub add permission for action-bot to commit to the protected branches - please merge release-* workflow into one
33

4-
name: Create Release Branch
4+
name: "[Deprecated] Create Release Branch"
55

66
on:
77
workflow_dispatch:

0 commit comments

Comments
 (0)