Skip to content

Commit 71271d0

Browse files
committed
Add Mirantis build and release workflows
1 parent 039f703 commit 71271d0

File tree

2 files changed

+105
-1
lines changed

2 files changed

+105
-1
lines changed
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Build and Push Container Images
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # Push events to matching v*
7+
workflow_dispatch: # Allow manual trigger
8+
inputs:
9+
tag:
10+
description: 'Tag to build (e.g., v0.13.0-mirantis.0)'
11+
required: true
12+
type: string
13+
14+
permissions:
15+
contents: read
16+
packages: write # Required for ghcr.io
17+
18+
env:
19+
# Mirantis registry configuration
20+
REGISTRY: ghcr.io/mirantis
21+
IMAGE_NAME: cluster-api-provider-openstack
22+
23+
jobs:
24+
build-and-push:
25+
name: Build and push multi-arch images
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Set tag environment
29+
run: |
30+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
31+
echo "TAG=${{ inputs.tag }}" >> $GITHUB_ENV
32+
else
33+
echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
34+
fi
35+
36+
- name: Checkout code
37+
uses: actions/checkout@v4
38+
with:
39+
fetch-depth: 0
40+
41+
- name: Calculate go version
42+
run: echo "go_version=$(make go-version)" >> $GITHUB_ENV
43+
44+
- name: Set up Go
45+
uses: actions/setup-go@v5
46+
with:
47+
go-version: ${{ env.go_version }}
48+
49+
- name: Set up Docker Buildx
50+
uses: docker/setup-buildx-action@v3
51+
52+
- name: Log in to GitHub Container Registry
53+
uses: docker/login-action@v3
54+
with:
55+
registry: ghcr.io
56+
username: ${{ github.actor }}
57+
password: ${{ secrets.GITHUB_TOKEN }}
58+
59+
- name: Extract metadata
60+
id: meta
61+
uses: docker/metadata-action@v5
62+
with:
63+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
64+
tags: |
65+
type=ref,event=tag
66+
type=raw,value=${{ env.TAG }}
67+
type=raw,value=latest,enable={{is_default_branch}}
68+
69+
- name: Build and push multi-arch image
70+
uses: docker/build-push-action@v5
71+
with:
72+
context: .
73+
file: ./Dockerfile
74+
platforms: linux/amd64,linux/arm,linux/arm64,linux/ppc64le,linux/s390x
75+
push: true
76+
tags: ${{ steps.meta.outputs.tags }}
77+
labels: ${{ steps.meta.outputs.labels }}
78+
build-args: |
79+
GO_VERSION=${{ env.go_version }}
80+
ldflags=${{ env.LDFLAGS }}
81+
cache-from: type=gha
82+
cache-to: type=gha,mode=max
83+
84+
- name: Generate image digest summary
85+
run: |
86+
echo "## Container Images Built 🐳" >> $GITHUB_STEP_SUMMARY
87+
echo "" >> $GITHUB_STEP_SUMMARY
88+
echo "| Image | Tag | Platform |" >> $GITHUB_STEP_SUMMARY
89+
echo "|-------|-----|----------|" >> $GITHUB_STEP_SUMMARY
90+
echo "| ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ${{ env.TAG }} | linux/amd64, linux/arm, linux/arm64, linux/ppc64le, linux/s390x |" >> $GITHUB_STEP_SUMMARY
91+
echo "" >> $GITHUB_STEP_SUMMARY
92+
echo "### Pull command:" >> $GITHUB_STEP_SUMMARY
93+
echo '```bash' >> $GITHUB_STEP_SUMMARY
94+
echo "docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}" >> $GITHUB_STEP_SUMMARY
95+
echo '```' >> $GITHUB_STEP_SUMMARY

.github/workflows/release.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ on:
99
permissions:
1010
contents: write # Allow to create a release.
1111

12+
env:
13+
# Mirantis registry configuration for manifest generation
14+
PROD_REGISTRY: ghcr.io/mirantis
15+
IMAGE_NAME: cluster-api-provider-openstack
16+
1217
jobs:
1318
build:
1419
name: create draft release
@@ -17,7 +22,7 @@ jobs:
1722
- name: Set env
1823
run: echo "RELEASE_TAG=${GITHUB_REF:10}" >> $GITHUB_ENV
1924
- name: checkout code
20-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2
25+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # tag=v5.0.0
2126
with:
2227
fetch-depth: 0
2328
- name: Calculate go version
@@ -29,6 +34,10 @@ jobs:
2934
- name: generate release artifacts
3035
run: |
3136
make release
37+
env:
38+
REGISTRY: ${{ env.PROD_REGISTRY }}
39+
PROD_REGISTRY: ${{ env.PROD_REGISTRY }}
40+
IMAGE_NAME: ${{ env.IMAGE_NAME }}
3241
- name: generate release notes
3342
# Ignore failures for release-notes generation so they could still get
3443
# generated manually before publishing.

0 commit comments

Comments
 (0)