Skip to content

Commit 003809c

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

25 files changed

+2007
-64
lines changed

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

Lines changed: 126 additions & 10 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,67 @@ 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/[email protected]'
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
382479
383480
- name: List installed packages in ${{ env.IMAGE_FILE }} cloud image
384481
if: ${{ ! contains(inputs.type, 'vagrant') }}
@@ -396,7 +493,7 @@ runs:
396493
# Image file format: raw or qcow2
397494
case ${{ inputs.type }} in
398495
oci|gencloud|opennebula) format=qcow2 ;;
399-
azure) format=raw ;;
496+
azure|gcp) format=raw ;;
400497
*) false ;;
401498
esac
402499
rootfs_path=/mnt/rootfs
@@ -410,8 +507,18 @@ runs:
410507
# Load nbd kernel module
411508
sudo modprobe nbd max_part=8
412509
413-
# Make a copy of the image file
414-
sudo cp ${{ env.IMAGE_FILE }} $(dirname ${rootfs_path})
510+
# Extract image if needed (GCP) or make a copy of it
511+
echo ${{ env.IMAGE_FILE }}
512+
case ${{ env.IMAGE_FILE }} in
513+
*.tar.gz)
514+
sudo tar -xzf ${{ env.IMAGE_FILE }} -C $(dirname ${rootfs_path})
515+
env.IMAGE_FILE=$(dirname ${rootfs_path})/disk.raw
516+
;;
517+
*)
518+
# Make a copy of the image file if it didn't need extracting
519+
sudo cp ${{ env.IMAGE_FILE }} $(dirname ${rootfs_path})
520+
;;
521+
esac
415522
416523
# Attach the image file to the nbd device
417524
sudo qemu-nbd \
@@ -532,6 +639,15 @@ runs:
532639
name: ${{ env.IMAGE_NAME }}
533640
path: ${{ env.IMAGE_FILE }}
534641

642+
- uses: actions/upload-artifact@v4
643+
name: Store repo metadata as artifact
644+
id: repo-meta-artifact
645+
if: inputs.store_as_artifact == 'true'
646+
with:
647+
compression-level: 9
648+
name: ${{ env.IMAGE_NAME }}.repo-metadata.txt
649+
path: ${{ env.IMAGE_FILE }}.repo-metadata.txt
650+
535651
- uses: actions/upload-artifact@v4
536652
name: Store checksum as artifact
537653
id: checksum-artifact
@@ -546,7 +662,7 @@ runs:
546662
id: pkglist-artifact
547663
if: inputs.store_as_artifact == 'true' && env.got_pkgs_list == 'true'
548664
with:
549-
compression-level: 1
665+
compression-level: 9
550666
name: ${{ env.IMAGE_NAME }}.txt
551667
path: ${{ env.IMAGE_FILE }}.txt
552668

.github/workflows/build.yml

Lines changed: 43 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
@@ -109,6 +110,10 @@ jobs:
109110
VARIANTS_GH+=("azure-x86_64")
110111
VARIANTS_SH+=("azure-aarch64")
111112
fi
113+
if [ "${{ inputs.image_type }}" = "gcp" -o "${{ inputs.image_type }}" = "ALL" ]; then
114+
VARIANTS_GH+=("gcp-x86_64")
115+
VARIANTS_SH+=("gcp-aarch64")
116+
fi
112117
# TODO: require data to work with the cloud, such as: bucket, access key, secret key, etc.
113118
# if [ "${{ inputs.image_type }}" = "digitalocean" -o "${{ inputs.image_type }}" = "ALL" ]; then
114119
# if [[ "${{ inputs.version_major }}" != *"kitten"* ]] && [[ "${{ inputs.version_major }}" != *"10" ]]; then
@@ -141,6 +146,14 @@ jobs:
141146
VARIANTS_SH+=("vagrant_vmware-x86_64") # VMware has networking issues on GitHub runners, so we use self-hosted runner
142147
fi
143148
149+
# Add SH values to matrix_gh if using runs-on
150+
if [ "${{ github.repository_owner }}" == 'AlmaLinux' ]; then
151+
for sh in "${VARIANTS_SH[@]}"; do
152+
VARIANTS_GH+=("$sh")
153+
done
154+
unset VARIANTS_SH
155+
fi
156+
144157
[ ${#VARIANTS_GH[@]} -ne 0 ] && matrix_gh=$(printf '"%s",' "${VARIANTS_GH[@]}")
145158
matrix_gh=${matrix_gh%,} # Remove the trailing comma
146159
echo matrix_gh=$(jq -c <<< [${matrix_gh}]) >> $GITHUB_OUTPUT
@@ -169,23 +182,34 @@ jobs:
169182
170183
build-gh-hosted:
171184
name: ${{ matrix.variant }} ${{ matrix.matrix_gh }} image
185+
permissions:
186+
id-token: write
187+
contents: read
172188
needs: [init-data]
173189
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' }}"
190+
# use runs-on runners if within the almalinux org, otherwise GH runners"
191+
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' }}"
175192
strategy:
176193
fail-fast: false
177194
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 )) }}
195+
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 )) }}
179196
matrix_gh: ${{ fromJSON(needs.init-data.outputs.matrix_gh) }}
180197
exclude:
181198
- matrix_gh: 'azure-x86_64'
182199
variant: '10-kitten-v2'
183200
- matrix_gh: 'oci-x86_64'
184201
variant: '10-kitten-v2'
202+
- matrix_gh: 'gcp-x86_64'
203+
variant: '10-kitten-v2'
204+
# Kitten x86_64_v2 Vagrant for VirtualBox stuck on "Waiting for SSH to become available"
205+
- matrix_gh: 'vagrant_virtualbox-x86_64'
206+
variant: '10-kitten-v2'
185207
- matrix_gh: 'digitalocean-x86_64'
186208
variant: '10-kitten-v2'
187209
- matrix_gh: 'azure-x86_64'
188210
variant: '10-v2'
211+
- matrix_gh: 'gcp-x86_64'
212+
variant: '10-v2'
189213
- matrix_gh: 'oci-x86_64'
190214
variant: '10-v2'
191215
- matrix_gh: 'digitalocean-x86_64'
@@ -204,7 +228,7 @@ jobs:
204228
echo "ARCH=$arch" >> $GITHUB_ENV
205229
206230
- name: Checkout ${{ github.action_repository }}
207-
uses: actions/checkout@v4
231+
uses: actions/checkout@v5
208232

209233
- uses: ./.github/actions/shared-steps
210234
name: ${{ matrix.variant }} ${{ matrix.matrix_gh }} image
@@ -221,14 +245,25 @@ jobs:
221245
store_as_artifact: ${{ inputs.store_as_artifact }}
222246
upload_to_s3: ${{ inputs.upload_to_s3 }}
223247
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' }}
248+
run_test: true # Do image simple testing and generate installed packages list (vagrant_* and GCP only)
249+
# runner: ${{ github.repository_owner == 'AlmaLinux' && 'aws-ec2' || 'gh_hosted' }}
250+
runner: gh_hosted
226251
env:
227252
PACKER_GITHUB_API_TOKEN: ${{ secrets.GIT_HUB_TOKEN }}
228253

254+
255+
256+
257+
258+
259+
260+
261+
### Everything below is for self-hosted runners only ###
262+
229263
start-self-hosted-runner:
230264
name: ${{ matrix.variant }} ${{ matrix.matrix_sh }} runner
231-
if: ${{ inputs.self-hosted && needs.init-data.outputs.matrix_sh != '[]' }}
265+
# If we're in the almalinux org we use runs-on for self-hosted
266+
if: ${{ github.repository_owner != 'AlmaLinux' && inputs.self-hosted && needs.init-data.outputs.matrix_sh != '[]' }}
232267
runs-on: ubuntu-24.04
233268
needs: [init-data]
234269
strategy:
@@ -297,6 +332,8 @@ jobs:
297332
exclude:
298333
- matrix_sh: 'oci-aarch64'
299334
variant: '10-kitten'
335+
- matrix_sh: 'oci-aarch64'
336+
variant: '10'
300337
- matrix_sh: 'oci-aarch64'
301338
variant: '9-64k'
302339
- matrix_sh: 'oci-aarch64'

0 commit comments

Comments
 (0)