Skip to content

Commit 22ff80f

Browse files
committed
Add GCP images for AlmaLinux 8, 9, and 10
1 parent 52efa0f commit 22ff80f

25 files changed

+2002
-61
lines changed

.github/actions/shared-steps/action.yml

Lines changed: 125 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ inputs:
3333
runs:
3434
using: "composite"
3535
steps:
36+
- uses: runs-on/action@v2
37+
# only when in runs-on environment
38+
if: env.RUNS_ON_VERSION != ''
39+
with:
40+
metrics: cpu,network,memory,disk,io
3641

3742
- name: Runner OS, install extra packages
3843
shell: bash
@@ -65,14 +70,15 @@ runs:
6570
echo "version_major=${version_major}" >> $GITHUB_ENV
6671
echo "alma_arch=${alma_arch}" >> $GITHUB_ENV
6772
68-
- name: Prepare staff
73+
- name: Prepare stuff
6974
shell: bash
7075
run: |
71-
# Prepare staff
76+
# Prepare stuff
77+
packer_opts=
7278
case ${{ env.runner_os }} in
7379
ubuntu)
7480
# Packer options
75-
packer_opts="-var ovmf_code=/usr/share/OVMF/OVMF_CODE_4M.fd -var ovmf_vars=/usr/share/OVMF/OVMF_VARS_4M.fd"
81+
packer_opts="-var qemu_binary=/usr/bin/qemu-system-${{ inputs.arch }} -var ovmf_code=/usr/share/OVMF/OVMF_CODE_4M.fd -var ovmf_vars=/usr/share/OVMF/OVMF_VARS_4M.fd"
7682
;;
7783
rhel)
7884
# Packer options
@@ -104,6 +110,10 @@ runs:
104110
# AWS S3 path to store images
105111
aws_s3_path=images/${{ env.version_major }}/${release}/${{ inputs.type }}/${{ env.TIME_STAMP }}
106112
113+
# tell packer we can use more cpu/ram if we're using runs-on
114+
# which means we're using runs-on with metal instances
115+
[[ ${{ env.RUNS_ON_VERSION }} != '' ]] && packer_opts="${packer_opts} -var cpus=$(($(nproc)-4)) -var memory_${{ env.alma_arch }}=32768"
116+
107117
# Overriding packer source, image mask and S3 path where necessary
108118
case "${{ inputs.type }}${{ env.version_major }}" in
109119
azure8|azure9)
@@ -218,6 +228,17 @@ runs:
218228
output_mask=output-${packer_source}/AlmaLinux-*.${{ env.alma_arch }}*.qcow2
219229
packer_source=qemu.${packer_source}
220230
;;
231+
gcp8|gcp9)
232+
output_mask=output-${packer_source}/AlmaLinux-*${version_major}*.${{ env.alma_arch }}.tar.gz
233+
packer_source=qemu.${packer_source}
234+
;;
235+
gcp10)
236+
packer_source=almalinux_${{ env.version_major }}_${{ inputs.type }}_${{ env.alma_arch }}
237+
[[ ${{ env.version_major }} == *"v2"* ]] && packer_source="${packer_source}_v2"
238+
[[ ${{ inputs.variant }} == *"64k"* ]] && packer_source="almalinux_${{ env.version_major }}_${{ inputs.type }}_64k_${{ env.alma_arch }}"
239+
output_mask=output-${packer_source}/AlmaLinux-*${version_major}*.${{ env.alma_arch }}.tar.gz
240+
packer_source=qemu.${packer_source}
241+
;;
221242
*)
222243
output_mask=output-${output_mask}
223244
packer_source=qemu.${packer_source}
@@ -250,8 +271,24 @@ runs:
250271
;;
251272
esac
252273
274+
- name: Remove KVM
275+
if: inputs.type == 'vagrant_virtualbox' || inputs.type == 'vagrant_vmware'
276+
shell: bash
277+
run: |
278+
# Remove KVM
279+
case ${{ env.runner_os }} in
280+
ubuntu)
281+
sudo apt-get -y remove qemu-kvm
282+
;;
283+
rhel)
284+
sudo dnf -y -q remove qemu-kvm
285+
;;
286+
esac
287+
sudo rmmod kvm_amd || sudo rmmod kvm_intel || true
288+
sudo rmmod kvm || true
289+
253290
- name: Check nested virtualization support
254-
if: inputs.arch == 'x86_64' && inputs.type != 'vagrant_virtualbox' && inputs.type != 'vagrant_vmware' && inputs.runner != 'aws-ec2'
291+
if: inputs.arch == 'x86_64' && env.RUNS_ON_VERSION == '' && inputs.type != 'vagrant_virtualbox' && inputs.type != 'vagrant_vmware'
255292
shell: bash
256293
run: |
257294
# Check nested virtualization support
@@ -363,6 +400,7 @@ runs:
363400
run: |
364401
# Build ${{ inputs.type }} image
365402
# PACKER_LOG=1
403+
sudo systemctl start libvirtd
366404
sudo sh -c "/usr/bin/packer build ${{ env.PACKER_OPTS }} -only=${{ env.packer_source }} ."
367405
368406
- name: Locate image file, generate checksum
@@ -377,8 +415,79 @@ runs:
377415
echo "IMAGE_FILE=${image_file}" >> $GITHUB_ENV
378416
echo "IMAGE_NAME=$(basename ${image_file})" >> $GITHUB_ENV
379417
380-
# - name: Setup tmate session
381-
# uses: mxschmitt/action-tmate@v3
418+
# don't fail if this doesn't exist, we may not always generate it
419+
sudo mv repo-metadata-*.txt $(basename ${image_file}).repo-metadata.txt || true
420+
421+
- id: 'google-auth-dev-images'
422+
if: env.IMAGE_TYPE == 'gcp'
423+
uses: 'google-github-actions/auth@v2'
424+
with:
425+
workload_identity_provider: 'projects/443728870479/locations/global/workloadIdentityPools/github-actions/providers/github'
426+
service_account: 'github-actions-cloud-images@almalinux-dev-images-469421.iam.gserviceaccount.com'
427+
428+
- name: 'Set up Google Cloud SDK'
429+
if: env.IMAGE_TYPE == 'gcp'
430+
uses: 'google-github-actions/setup-gcloud@v3.0.0'
431+
432+
- name: 'Upload output to GCP storage bucket'
433+
if: env.IMAGE_TYPE == 'gcp'
434+
shell: bash
435+
run: gcloud storage cp ${{ env.IMAGE_FILE }} gs://almalinux-images-dev/almalinux-${version_major}${{ inputs.arch == 'aarch64' && '-arm64' || '' }}-v$(date +'%Y%m%d')/root.tar.gz
436+
437+
- name: Clone gce_image_publish repo
438+
if: env.IMAGE_TYPE == 'gcp'
439+
uses: actions/checkout@v5
440+
with:
441+
path: compute-image-tools
442+
repository: GoogleCloudPlatform/compute-image-tools
443+
ref: "20250916.00"
444+
445+
- name: Build gce_image_publish tool
446+
if: env.IMAGE_TYPE == 'gcp'
447+
shell: bash
448+
run: |
449+
# we need golang
450+
case ${{ env.runner_os }} in
451+
ubuntu)
452+
sudo apt update
453+
sudo apt-get -y install golang-go
454+
;;
455+
rhel)
456+
sudo dnf -y -q install golang
457+
;;
458+
esac
459+
# print golang version for reference
460+
go version
461+
# Build gce_image_publish tool
462+
cd compute-image-tools/cli_tools/gce_image_publish
463+
go mod tidy
464+
go install
465+
466+
- name: Create test image on GCP
467+
if: env.IMAGE_TYPE == 'gcp'
468+
shell: bash
469+
run: |
470+
/home/$USER/go/bin/gce_image_publish \
471+
-var:environment=test \
472+
-skip_confirmation \
473+
-rollout_rate=0 \
474+
-publish_project="almalinux-dev-images-469421" \
475+
-work_project="almalinux-dev-images-469421" \
476+
-replace \
477+
-source_gcs_path="gs://almalinux-images-dev/" \
478+
vm-scripts/gcp/almalinux_${version_major}${{ inputs.arch == 'aarch64' && '_arm64' || '' }}.publish.json
479+
480+
# - name: 'Run Google cloud-image-testing tests (basic suite)'
481+
# if: env.IMAGE_TYPE == 'gcp' && inputs.run_test == 'true'
482+
# shell: bash
483+
# run: |
484+
# cd cloud-image-tests
485+
# ./bin/manager \
486+
# -local_path bin \
487+
# -project almalinux-image-testing-469421 \
488+
# -filter '^(cvm|livemigrate|suspendresume|loadbalancer|guestagent|hostnamevalidation|imageboot|licensevalidation|network|security|hotattach|lssd|disk|packagevalidation|ssh|metadata|vmspec)$' \
489+
# -images 'projects/almalinux-dev-images-469421/global/images/family/almalinux-${{ env.version_major }}${{ inputs.arch == 'aarch64' && '-arm64' || '' }}' \
490+
# -parallel_stagger 10s -parallel_count 20
382491

383492
- name: List installed packages in ${{ env.IMAGE_FILE }} cloud image
384493
if: ${{ ! contains(inputs.type, 'vagrant') }}
@@ -532,6 +641,15 @@ runs:
532641
name: ${{ env.IMAGE_NAME }}
533642
path: ${{ env.IMAGE_FILE }}
534643

644+
- uses: actions/upload-artifact@v4
645+
name: Store repo metadata as artifact
646+
id: repo-meta-artifact
647+
if: inputs.store_as_artifact == 'true'
648+
with:
649+
compression-level: 9
650+
name: ${{ env.IMAGE_NAME }}.repo-metadata.txt
651+
path: ${{ env.IMAGE_FILE }}.repo-metadata.txt
652+
535653
- uses: actions/upload-artifact@v4
536654
name: Store checksum as artifact
537655
id: checksum-artifact
@@ -546,7 +664,7 @@ runs:
546664
id: pkglist-artifact
547665
if: inputs.store_as_artifact == 'true' && env.got_pkgs_list == 'true'
548666
with:
549-
compression-level: 1
667+
compression-level: 9
550668
name: ${{ env.IMAGE_NAME }}.txt
551669
path: ${{ env.IMAGE_FILE }}.txt
552670

.github/workflows/build.yml

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ on:
3030
- ALL
3131
- azure
3232
# - digitalocean # TODO: require data to work with the cloud, such as: bucket, access key, secret key, etc.
33+
- gcp
3334
- gencloud
3435
- oci
3536
- opennebula
@@ -141,6 +142,14 @@ jobs:
141142
VARIANTS_SH+=("vagrant_vmware-x86_64") # VMware has networking issues on GitHub runners, so we use self-hosted runner
142143
fi
143144
145+
# Add SH values to matrix_gh if using runs-on
146+
if [ "${{ github.repository_owner }}" == 'AlmaLinux' ]; then
147+
for sh in "${VARIANTS_SH[@]}"; do
148+
VARIANTS_GH+=("$sh")
149+
done
150+
unset VARIANTS_SH
151+
fi
152+
144153
[ ${#VARIANTS_GH[@]} -ne 0 ] && matrix_gh=$(printf '"%s",' "${VARIANTS_GH[@]}")
145154
matrix_gh=${matrix_gh%,} # Remove the trailing comma
146155
echo matrix_gh=$(jq -c <<< [${matrix_gh}]) >> $GITHUB_OUTPUT
@@ -169,23 +178,34 @@ jobs:
169178
170179
build-gh-hosted:
171180
name: ${{ matrix.variant }} ${{ matrix.matrix_gh }} image
181+
permissions:
182+
id-token: write
183+
contents: read
172184
needs: [init-data]
173185
if: ${{ needs.init-data.outputs.matrix_gh != '[]' }}
174-
runs-on: "${{ github.repository_owner == 'AlmaLinux' && format('runs-on={0}/family=c7i.metal-24xl+c7a.metal-48xl+*8gd.metal*/image=ubuntu24-full-x64', github.run_id) || 'ubuntu-24.04' }}"
186+
# use runs-on runners if within the almalinux org, otherwise GH runners"
187+
runs-on: "${{ github.repository_owner == 'AlmaLinux' && format('runs-on={0}/family=c7i.metal-24xl+c7a.metal-48xl+*8gd.metal*/image=ubuntu24-full-{2}', github.run_id, matrix.variant, contains(matrix.matrix_gh, 'aarch64') && 'arm64' || 'x64') || 'ubuntu-24.04' }}"
175188
strategy:
176189
fail-fast: false
177190
matrix:
178-
variant: ${{ fromJSON(format('["{0}"]', ( inputs.version_major == '10-kitten' || inputs.version_major == '10' ) && format('{0}", "{0}-v2', inputs.version_major) || inputs.version_major )) }}
191+
variant: ${{ fromJSON(format('["{0}"]', ( (inputs.version_major == '10-kitten' || inputs.version_major == '10') && !(contains(needs.init-data.outputs.matrix_gh, 'aarch64') ) ) && format('{0}", "{0}-v2', inputs.version_major) || inputs.version_major )) }}
179192
matrix_gh: ${{ fromJSON(needs.init-data.outputs.matrix_gh) }}
180193
exclude:
181194
- matrix_gh: 'azure-x86_64'
182195
variant: '10-kitten-v2'
183196
- matrix_gh: 'oci-x86_64'
184197
variant: '10-kitten-v2'
198+
- matrix_gh: 'gcp-x86_64'
199+
variant: '10-kitten-v2'
200+
# Kitten x86_64_v2 Vagrant for VirtualBox stuck on "Waiting for SSH to become available"
201+
- matrix_gh: 'vagrant_virtualbox-x86_64'
202+
variant: '10-kitten-v2'
185203
- matrix_gh: 'digitalocean-x86_64'
186204
variant: '10-kitten-v2'
187205
- matrix_gh: 'azure-x86_64'
188206
variant: '10-v2'
207+
- matrix_gh: 'gcp-x86_64'
208+
variant: '10-v2'
189209
- matrix_gh: 'oci-x86_64'
190210
variant: '10-v2'
191211
- matrix_gh: 'digitalocean-x86_64'
@@ -204,7 +224,7 @@ jobs:
204224
echo "ARCH=$arch" >> $GITHUB_ENV
205225
206226
- name: Checkout ${{ github.action_repository }}
207-
uses: actions/checkout@v4
227+
uses: actions/checkout@v5
208228

209229
- uses: ./.github/actions/shared-steps
210230
name: ${{ matrix.variant }} ${{ matrix.matrix_gh }} image
@@ -221,14 +241,25 @@ jobs:
221241
store_as_artifact: ${{ inputs.store_as_artifact }}
222242
upload_to_s3: ${{ inputs.upload_to_s3 }}
223243
notify_mattermost: ${{ inputs.notify_mattermost }}
224-
run_test: ${{ contains(env.type, 'vagrant') && inputs.run_test && 'true' || 'false' }} # Do image simple testing and generate installed packages list (vagrant_* only)
225-
runner: ${{ github.repository_owner == 'AlmaLinux' && 'aws-ec2' || 'gh_hosted' }}
244+
run_test: true # Do image simple testing and generate installed packages list (vagrant_* and GCP only)
245+
# runner: ${{ github.repository_owner == 'AlmaLinux' && 'aws-ec2' || 'gh_hosted' }}
246+
runner: gh_hosted
226247
env:
227248
PACKER_GITHUB_API_TOKEN: ${{ secrets.GIT_HUB_TOKEN }}
228249

250+
251+
252+
253+
254+
255+
256+
257+
### Everything below is for self-hosted runners only ###
258+
229259
start-self-hosted-runner:
230260
name: ${{ matrix.variant }} ${{ matrix.matrix_sh }} runner
231-
if: ${{ inputs.self-hosted && needs.init-data.outputs.matrix_sh != '[]' }}
261+
# If we're in the almalinux org we use runs-on for self-hosted
262+
if: ${{ github.repository_owner != 'AlmaLinux' && inputs.self-hosted && needs.init-data.outputs.matrix_sh != '[]' }}
232263
runs-on: ubuntu-24.04
233264
needs: [init-data]
234265
strategy:
@@ -297,6 +328,8 @@ jobs:
297328
exclude:
298329
- matrix_sh: 'oci-aarch64'
299330
variant: '10-kitten'
331+
- matrix_sh: 'oci-aarch64'
332+
variant: '10'
300333
- matrix_sh: 'oci-aarch64'
301334
variant: '9-64k'
302335
- matrix_sh: 'oci-aarch64'

0 commit comments

Comments
 (0)