Skip to content

Commit 32f933a

Browse files
committed
feat: dirty commit with new promote pipeline
1 parent e241659 commit 32f933a

File tree

3 files changed

+153
-16
lines changed

3 files changed

+153
-16
lines changed

.github/actions/image2commit/action.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ inputs:
1515
outputs:
1616
commit_sha:
1717
description: "Resolved full commit SHA"
18-
18+
value: ${{ steps.resolve.outputs.commit_sha }}
1919
runs:
2020
using: "composite"
2121
steps:
@@ -37,4 +37,6 @@ runs:
3737
"${{ inputs.repo }}" \
3838
"${{ inputs.image_sha }}"
3939
)
40+
41+
echo "Raw full_sha: $full_sha"
4042
echo "commit_sha=$full_sha" >> $GITHUB_OUTPUT

.github/workflows/promote-image.yml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,18 @@ on:
44
workflow_run:
55
workflows: ["Test"]
66
types: [completed]
7+
push:
8+
branches:
9+
- '**'
710

811
jobs:
912
promote-image:
1013
runs-on: ubuntu-latest
1114
environment: release
12-
if: |
13-
github.event.workflow_run.head_branch == 'main' &&
14-
github.event.workflow_run.conclusion == 'success' &&
15-
github.event.workflow_run.event == 'schedule'
1615
env:
17-
GHCR_REPO: ghcr.io/andrpac/mongodb-atlas-kubernetes-operator-prerelease
18-
DOCKER_REPO: docker.io/andrpac/mongodb-atlas-kubernetes-operator-prerelease
19-
QUAY_REPO: quay.io/andrpac/mongodb-atlas-kubernetes-operator-prerelease
16+
GHCR_REPO: ghcr.io/mongodb/mongodb-atlas-kubernetes-operator-prerelease
17+
DOCKER_REPO: docker.io/mongodb/mongodb-atlas-kubernetes-operator-prerelease
18+
QUAY_REPO: quay.io/mongodb/mongodb-atlas-kubernetes-operator-prerelease
2019
steps:
2120
- name: Checkout PR commit
2221
uses: actions/checkout@v4

.github/workflows/release-image.yml

Lines changed: 144 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,32 @@ on:
1616
required: false
1717
default: "latest"
1818
type: string
19-
19+
push:
20+
branches:
21+
- '**'
22+
2023
permissions:
2124
contents: write
2225
pull-requests: write
2326

2427
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: Creates a mapping between the image_sha given as input and the actual git commit
29+
# This is necassary for the release-image step that requires checking out that exact git commit
2830
image2commit:
2931
name: Resolve Commit SHA from Image
3032
runs-on: ubuntu-latest
3133
outputs:
3234
commit_sha: ${{ steps.resolve.outputs.commit_sha }}
33-
3435
steps:
36+
- name: Checkout code
37+
uses: actions/checkout@v4
38+
3539
- name: Log in to Docker registry
3640
uses: docker/login-action@v3
3741
with:
3842
registry: docker.io
39-
username: ${{ secrets.DOCKER_USERNAME }}
40-
password: ${{ secrets.DOCKER_PASSWORD }}
43+
username: ${{ secrets.ANDRPAC_DOCKER_USERNAME }}
44+
password: ${{ secrets.ANDRPAC_DOCKER_PASSWORD }}
4145

4246
- name: Run image2commit
4347
id: resolve
@@ -56,6 +60,128 @@ jobs:
5660
run: |
5761
echo "Resolved commit: ${{ needs.image2commit.outputs.commit_sha }}"
5862
63+
# Release-image: Created and uploads a release for the specified operator version given in the image_sha
64+
# Note, with new releases, all of the release artifacts will be stored withing docs/releases/{release_version}
65+
release-image:
66+
runs-on: ubuntu-latest
67+
environment: release
68+
needs: image2commit
69+
env:
70+
VERSION: ${{ github.event.inputs.version || 'test-0.0.0-dev' }}
71+
AUTHORS: ${{ github.event.inputs.authors || 'unknown' }}
72+
IMAGE_SHA: ${{ github.event.inputs.image_sha || 'latest' }}
73+
DOCKER_SIGNATURE_REPO: docker.io/andrpac/signatures
74+
DOCKER_RELEASE_REPO: docker.io/andrpac/mongodb-atlas-kubernetes-operator
75+
DOCKER_PRERELEASE_REPO: docker.io/andrpac/mongodb-atlas-kubernetes-operator-prerelease
76+
QUAY_RELEASE_REPO: quay.io/andrpac/mongodb-atlas-kubernetes-operator
77+
QUAY_PRERELEASE_REPO: quay.io/andrpac/mongodb-atlas-kubernetes-operator-prerelease
78+
steps:
79+
- name: Checkout code
80+
uses: actions/checkout@v4
81+
with:
82+
fetch-depth: 0
83+
#ref: $#{{ needs.image2commit.outputs.commit_sha }} !!!!!!!!! SUPER IMPORTNAT TO PUT BACK !!!!!!!
84+
85+
- name: Generate GitHub App Token
86+
id: generate_token
87+
uses: mongodb/apix-action/token@v8
88+
with:
89+
app-id: ${{ secrets.AKO_RELEASER_APP_ID }}
90+
private-key: ${{ secrets.AKO_RELEASER_RSA_KEY }}
91+
92+
# Login in into all registries
93+
- name: Log in to Docker registry
94+
uses: docker/login-action@v3
95+
with:
96+
registry: docker.io
97+
username: ${{ secrets.ANDRPAC_DOCKER_USERNAME }}
98+
password: ${{ secrets.ANDRPAC_DOCKER_PASSWORD }}
99+
100+
- name: Log in to Quay registry
101+
uses: docker/login-action@v3
102+
with:
103+
registry: quay.io
104+
username: ${{ secrets.ANDRPAC_QUAY_USERNAME }}
105+
password: ${{ secrets.ANDRPAC_QUAY_PASSWORD }}
106+
107+
- name: Install devbox
108+
uses: jetify-com/[email protected]
109+
110+
# This step configures all of the dynamic variables needed for later steps
111+
- name: Configure job environment for downstream steps
112+
id: tags
113+
run: |
114+
promoted_tag="promoted-${IMAGE_SHA}"
115+
release_tag="${VERSION}"
116+
certified_tag="certified-${release_tag}"
117+
118+
docker_image_url="${DOCKER_RELEASE_REPO}:${release_tag}"
119+
quay_image_url="${QUAY_RELEASE_REPO}:${release_tag}"
120+
quay_certified_image_url="${QUAY_RELEASE_REPO}:${certified_tag}"
121+
122+
echo "promoted_tag=$promoted_tag" >> $GITHUB_OUTPUT
123+
echo "release_tag=$release_tag" >> $GITHUB_OUTPUT
124+
echo "certified_tag=$certified_tag" >> $GITHUB_OUTPUT
125+
echo "docker_image_url=$docker_image_url" >> $GITHUB_OUTPUT
126+
echo "quay_image_url=$quay_image_url" >> $GITHUB_OUTPUT
127+
echo "quay_certified_image_url=$quay_certified_image_url" >> $GITHUB_OUTPUT
128+
129+
# Move prerelease images to official release registries in Docker Hub and Quay
130+
- name: Move image to Docker registry release from prerelease
131+
run: devbox run -- ./scripts/move-image.sh
132+
env:
133+
IMAGE_SRC_REPO: ${{ env.DOCKER_PRERELEASE_REPO }}
134+
IMAGE_DEST_REPO: ${{ env.DOCKER_RELEASE_REPO }}
135+
IMAGE_SRC_TAG: ${{ steps.tags.outputs.promoted_tag }}
136+
IMAGE_DEST_TAG: ${{ github.event.inputs.version }}
137+
138+
- name: Move image to Quay registry release from prerelease
139+
run: devbox run -- ./scripts/move-image.sh
140+
env:
141+
IMAGE_SRC_REPO: ${{ env.QUAY_PRERELEASE_REPO }}
142+
IMAGE_DEST_REPO: ${{ env.QUAY_RELEASE_REPO }}
143+
IMAGE_SRC_TAG: ${{ steps.tags.outputs.promoted_tag }}
144+
IMAGE_DEST_TAG: ${{ github.event.inputs.version }}
145+
146+
# Create Openshift certified images
147+
- name: Create OpenShift certified image on Quay
148+
run: devbox run -- ./scripts/move-image.sh
149+
env:
150+
IMAGE_SRC_REPO: ${{ env.QUAY_PRERELEASE_REPO }}
151+
IMAGE_DEST_REPO: ${{ env.QUAY_RELEASE_REPO }}
152+
IMAGE_SRC_TAG: ${{ steps.tags.outputs.promoted_tag }}
153+
IMAGE_DEST_TAG: ${{ steps.tags.outputs.certified_tag }}
154+
155+
# Link updates to pr: all-in-one.yml, helm-updates, sdlc requirements
156+
- name: Generate deployment configurations
157+
uses: ./.github/actions/gen-install-scripts
158+
with:
159+
ENV: prod
160+
IMAGE_URL: ${{ steps.tags.outputs.docker_image_url }}
161+
162+
- name: Bump Helm chart version
163+
run: devbox run -- ./scripts/bump-helm-chart-version.sh
164+
165+
# Prepare SDLC requirement: signatures, sboms, compliance reports
166+
# Note, signed images will live in mongodb/release and mongodb/signature repos
167+
- name: Sign released images
168+
run: |
169+
devbox run -- make sign IMG="${{ steps.tags.outputs.docker_image_url }}" SIGNATURE_REPO="${{ env.DOCKER_RELEASE_REPO }}"
170+
devbox run -- make sign IMG="${{ steps.tags.outputs.quay_image_url }}" SIGNATURE_REPO="${{ env.QUAY_RELEASE_REPO }}"
171+
devbox run -- make sign IMG="${{ steps.tags.outputs.docker_image_url }}" SIGNATURE_REPO="${{ env.DOCKER_SIGNATURE_REPO }}"
172+
devbox run -- make sign IMG="${{ steps.tags.outputs.quay_certified_image_url }}" SIGNATURE_REPO="${{ env.QUAY_RELEASE_REPO }}"
173+
devbox run -- make sign IMG="${{ steps.tags.outputs.quay_certified_image_url }}" SIGNATURE_REPO="${{ env.DOCKER_SIGNATURE_REPO }}"
174+
env:
175+
PKCS11_URI: ${{ secrets.PKCS11_URI }}
176+
GRS_USERNAME: ${{ secrets.GRS_USERNAME }}
177+
GRS_PASSWORD: ${{ secrets.GRS_PASSWORD }}
178+
179+
- name: Generate SBOMs
180+
run: devbox run -- make generate-sboms RELEASED_OPERATOR_IMAGE="${{ env.DOCKER_RELEASE_REPO }}"
181+
182+
- name: Create SDLC report
183+
run: devbox run -- make gen-sdlc-checklist
184+
59185
prepare-environment:
60186
name: Set up Environment Variables
61187
runs-on: ubuntu-latest
@@ -151,7 +277,7 @@ jobs:
151277
echo "quay_image_url=$quay_image_url" >> $GITHUB_OUTPUT
152278
echo "quay_certified_image_url=$quay_certified_image_url" >> $GITHUB_OUTPUT
153279
154-
release-image:
280+
release-image1:
155281
runs-on: ubuntu-latest
156282
if: false
157283
environment: release
@@ -205,6 +331,7 @@ jobs:
205331
short_sha="${sha:0:6}"
206332
echo "promoted_tag=promoted-${short_sha}" >> "$GITHUB_OUTPUT"
207333
334+
# Move prerelease images to official release registries in Docker Hub and Quay
208335
- name: Move image to Docker registry release from prerelease
209336
run: devbox run -- ./scripts/move-image.sh
210337
env:
@@ -220,6 +347,15 @@ jobs:
220347
IMAGE_DEST_REPO: ${{ env.QUAY_RELEASE_REPO }}
221348
IMAGE_SRC_TAG: ${{ steps.tags.outputs.promoted_tag }}
222349
IMAGE_DEST_TAG: ${{ github.event.inputs.version }}
350+
351+
# Create Openshift certified images
352+
- name: Create OpenShift certified image on Quay
353+
run: devbox run -- ./scripts/move-image.sh
354+
env:
355+
IMAGE_SRC_REPO: ${{ env.QUAY_PRERELEASE_REPO }}
356+
IMAGE_DEST_REPO: ${{ env.QUAY_RELEASE_REPO }}
357+
IMAGE_SRC_TAG: ${{ steps.tags.outputs.promoted_tag }}
358+
IMAGE_DEST_TAG: ${{ steps.tags.outputs.certified_tag }}
223359

224360
- name: Create deploy configurations
225361
uses: ./.github/actions/gen-install-scripts

0 commit comments

Comments
 (0)