Skip to content

Commit 40fa854

Browse files
authored
Merge pull request #5138 from richardcase/image_build
✨ chore: workflow to build and publish AMIs
2 parents 1245ff7 + 6783289 commit 40fa854

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed

.github/workflows/build-ami.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: build-and-publish-ami
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
regions:
7+
description: 'Publication regions'
8+
required: true
9+
default: 'ap-south-1,eu-west-3,eu-west-2,eu-west-1,ap-northeast-2,ap-northeast-1,sa-east-1,ca-central-1,ap-southeast-1,ap-southeast-2,eu-central-1,us-east-1,us-east-2,us-west-1,us-west-2'
10+
k8s_semver:
11+
description: 'K8s Semver'
12+
required: true
13+
k8s_series:
14+
description: 'K8s Release Series (major.minor version)'
15+
required: true
16+
k8s_rpm_version:
17+
description: 'K8s rpm package version'
18+
required: true
19+
k8s_deb_version:
20+
description: 'K8s deb package version'
21+
required: true
22+
cni_semver:
23+
description: 'CNI Semver'
24+
required: true
25+
cni_deb_version:
26+
description: 'CNI deb package version'
27+
required: true
28+
crictl_version:
29+
description: 'Crictl version'
30+
required: true
31+
32+
permissions:
33+
id-token: write
34+
contents: read
35+
36+
jobs:
37+
buildandpublish:
38+
concurrency:
39+
group: ${{ github.workflow }}-${{ github.ref }}
40+
cancel-in-progress: false
41+
strategy:
42+
matrix:
43+
target: ['ubuntu-2204', 'ubuntu-2404', 'flatcar', 'rhel-8']
44+
name: Build and publish CAPA AMIs
45+
runs-on: ubuntu-latest
46+
steps:
47+
- name: checkout code
48+
uses: actions/checkout@v4
49+
with:
50+
repository: kubernetes-sigs/image-builder
51+
fetch-depth: 0
52+
- name: Configure AWS credentials
53+
uses: aws-actions/configure-aws-credentials@v4
54+
with:
55+
aws-region: us-east-2
56+
role-to-assume: arn:aws:iam::819546954734:role/gh-image-builder
57+
- name: Install deps
58+
run: make deps-ami
59+
working-directory: ./images/capi
60+
- name: Install Amazon EBS Plugin
61+
working-directory: ./images/capi
62+
run: ./.local/bin/packer plugins install github.com/hashicorp/amazon
63+
- name: Create Packer Args
64+
env:
65+
K8S_RPM_VERSION: ${{ inputs.k8s_rpm_version }}
66+
K8S_SEMVER: ${{ inputs.k8s_semver }}
67+
K8S_SERIES: ${{ inputs.k8s_series }}
68+
K8S_DEB_VERSION: ${{ inputs.k8s_deb_version }}
69+
CNI_SEMVER: ${{ inputs.cni_semver }}
70+
CNI_DEB_VERSION: ${{ inputs.cni_deb_version }}
71+
CRICTL_VERSION: ${{ inputs.crictl_version }}
72+
AMI_REGIONS: ${{ inputs.regions }}
73+
run: |
74+
cat > ./images/capi/vars.json << EOF
75+
{
76+
"kubernetes_rpm_version": "$K8S_RPM_VERSION",
77+
"kubernetes_semver": "$K8S_SEMVER",
78+
"kubernetes_series": "$K8S_SERIES",
79+
"kubernetes_deb_version": "$K8S_DEB_VERSION",
80+
"kubernetes_cni_semver": "$CNI_SEMVER",
81+
"kubernetes_cni_deb_version": "$CNI_DEB_VERSION",
82+
"crictl_version": "$CRICTL_VERSION",
83+
"ami_regions": "$AMI_REGIONS"
84+
}
85+
EOF
86+
- name: Show vars
87+
run: cat ./images/capi/vars.json
88+
- name: Build AMI
89+
working-directory: ./images/capi
90+
run: PACKER_VAR_FILES=vars.json make build-ami-${{ matrix.target }}
91+

0 commit comments

Comments
 (0)