@@ -33,6 +33,11 @@ inputs:
3333runs :
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
0 commit comments