@@ -41,6 +41,11 @@ inputs:
4141runs :
4242 using : " composite"
4343 steps :
44+ - uses : runs-on/action@v2
45+ # only when in runs-on environment
46+ if : env.RUNS_ON_VERSION != ''
47+ with :
48+ metrics : cpu,network,memory,disk,io
4449
4550 - name : Runner OS, install extra packages
4651 shell : bash
@@ -73,14 +78,15 @@ runs:
7378 echo "version_major=${version_major}" >> $GITHUB_ENV
7479 echo "alma_arch=${alma_arch}" >> $GITHUB_ENV
7580
76- - name : Prepare staff
81+ - name : Prepare stuff
7782 shell : bash
7883 run : |
79- # Prepare staff
84+ # Prepare stuff
85+ packer_opts=
8086 case ${{ env.runner_os }} in
8187 ubuntu)
8288 # Packer options
83- packer_opts="-var ovmf_code=/usr/share/OVMF/OVMF_CODE_4M.fd -var ovmf_vars=/usr/share/OVMF/OVMF_VARS_4M.fd"
89+ 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"
8490 ;;
8591 rhel)
8692 # Packer options
@@ -114,6 +120,10 @@ runs:
114120 # AWS S3 path to store images
115121 aws_s3_path=images/${{ env.version_major }}/${release}/${{ inputs.type }}/${{ env.TIME_STAMP }}
116122
123+ # tell packer we can use more cpu/ram if we're using runs-on
124+ # which means we're using runs-on with metal instances
125+ [[ ${{ env.RUNS_ON_VERSION }} != '' ]] && packer_opts="${packer_opts} -var cpus=$(($(nproc)-4)) -var memory_${{ env.alma_arch }}=32768"
126+
117127 # Overriding packer source, image mask and S3 path where necessary
118128 case "${{ inputs.type }}${{ env.version_major }}" in
119129 azure8|azure9)
@@ -228,6 +238,17 @@ runs:
228238 output_mask=output-${packer_source}/AlmaLinux-*.${{ env.alma_arch }}*.qcow2
229239 packer_source=qemu.${packer_source}
230240 ;;
241+ gcp8|gcp9)
242+ output_mask=output-${packer_source}/AlmaLinux-*${version_major}*.${{ env.alma_arch }}.tar.gz
243+ packer_source=qemu.${packer_source}
244+ ;;
245+ gcp10)
246+ packer_source=almalinux_${{ env.version_major }}_${{ inputs.type }}_${{ env.alma_arch }}
247+ [[ ${{ env.version_major }} == *"v2"* ]] && packer_source="${packer_source}_v2"
248+ [[ ${{ inputs.variant }} == *"64k"* ]] && packer_source="almalinux_${{ env.version_major }}_${{ inputs.type }}_64k_${{ env.alma_arch }}"
249+ output_mask=output-${packer_source}/AlmaLinux-*${version_major}*.${{ env.alma_arch }}.tar.gz
250+ packer_source=qemu.${packer_source}
251+ ;;
231252 *)
232253 output_mask=output-${output_mask}
233254 packer_source=qemu.${packer_source}
@@ -260,8 +281,24 @@ runs:
260281 ;;
261282 esac
262283
284+ - name : Remove KVM
285+ if : inputs.type == 'vagrant_virtualbox' || inputs.type == 'vagrant_vmware'
286+ shell : bash
287+ run : |
288+ # Remove KVM
289+ case ${{ env.runner_os }} in
290+ ubuntu)
291+ sudo apt-get -y remove qemu-kvm
292+ ;;
293+ rhel)
294+ sudo dnf -y -q remove qemu-kvm
295+ ;;
296+ esac
297+ sudo rmmod kvm_amd || sudo rmmod kvm_intel || true
298+ sudo rmmod kvm || true
299+
263300 - name : Check nested virtualization support
264- if : inputs.arch == 'x86_64' && inputs.type != 'vagrant_virtualbox ' && inputs.type != 'vagrant_vmware ' && inputs.runner != 'aws-ec2 '
301+ if : inputs.arch == 'x86_64' && env.RUNS_ON_VERSION == ' ' && inputs.type != 'vagrant_virtualbox ' && inputs.type != 'vagrant_vmware '
265302 shell : bash
266303 run : |
267304 # Check nested virtualization support
@@ -365,12 +402,13 @@ runs:
365402 run : |
366403 # Build ${{ inputs.type }} image
367404 # PACKER_LOG=1
405+ sudo systemctl start libvirtd
368406 sudo sh -c "/usr/bin/packer build ${{ env.PACKER_OPTS }} -only=${{ env.packer_source }} ."
369407
370408 - name : Locate image file, generate checksum
371409 shell : bash
372410 run : |
373- # Locate image file, generate checksum
411+ # Locate image file, generate checksum, rename repo metadata file
374412 ls -la $(dirname '${{ env.output_mask }}')
375413 image_file=$(ls -1 ${{ env.output_mask }} | head -n 1)
376414 [ "x${image_file}" = "x" ] && false
@@ -380,8 +418,79 @@ runs:
380418 echo "IMAGE_FILE=${image_file}" >> $GITHUB_ENV
381419 echo "IMAGE_NAME=$(basename ${image_file})" >> $GITHUB_ENV
382420
383- # - name: Setup tmate session
384- # uses: mxschmitt/action-tmate@v3
421+ # don't fail if this doesn't exist, we may not always generate it
422+ sudo mv repo-metadata-*.txt $(basename ${image_file}).repo-metadata.txt || true
423+
424+ - id : ' google-auth-dev-images'
425+ if : env.IMAGE_TYPE == 'gcp'
426+ uses : ' google-github-actions/auth@v2'
427+ with :
428+ workload_identity_provider : ' projects/443728870479/locations/global/workloadIdentityPools/github-actions/providers/github'
429+ service_account : ' github-actions-cloud-images@almalinux-dev-images-469421.iam.gserviceaccount.com'
430+
431+ - name : ' Set up Google Cloud SDK'
432+ if : env.IMAGE_TYPE == 'gcp'
433+ uses :
' google-github-actions/[email protected] ' 434+
435+ - name : ' Upload output to GCP storage bucket'
436+ if : env.IMAGE_TYPE == 'gcp'
437+ shell : bash
438+ 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
439+
440+ - name : Clone gce_image_publish repo
441+ if : env.IMAGE_TYPE == 'gcp'
442+ uses : actions/checkout@v5
443+ with :
444+ path : compute-image-tools
445+ repository : GoogleCloudPlatform/compute-image-tools
446+ ref : " 20250916.00"
447+
448+ - name : Build gce_image_publish tool
449+ if : env.IMAGE_TYPE == 'gcp'
450+ shell : bash
451+ run : |
452+ # we need golang
453+ case ${{ env.runner_os }} in
454+ ubuntu)
455+ sudo apt update
456+ sudo apt-get -y install golang-go
457+ ;;
458+ rhel)
459+ sudo dnf -y -q install golang
460+ ;;
461+ esac
462+ # print golang version for reference
463+ go version
464+ # Build gce_image_publish tool
465+ cd compute-image-tools/cli_tools/gce_image_publish
466+ go mod tidy
467+ go install
468+
469+ - name : Create test image on GCP
470+ if : env.IMAGE_TYPE == 'gcp'
471+ shell : bash
472+ run : |
473+ /home/$USER/go/bin/gce_image_publish \
474+ -var:environment=test \
475+ -skip_confirmation \
476+ -rollout_rate=0 \
477+ -publish_project="almalinux-dev-images-469421" \
478+ -work_project="almalinux-dev-images-469421" \
479+ -replace \
480+ -source_gcs_path="gs://almalinux-images-dev/" \
481+ vm-scripts/gcp/almalinux_${version_major}${{ inputs.arch == 'aarch64' && '_arm64' || '' }}.publish.json
482+
483+ # - name: 'Run Google cloud-image-testing tests (basic suite)'
484+ # if: env.IMAGE_TYPE == 'gcp' && inputs.run_test == 'true'
485+ # shell: bash
486+ # run: |
487+ # cd cloud-image-tests
488+ # ./bin/manager \
489+ # -local_path bin \
490+ # -project almalinux-image-testing-469421 \
491+ # -filter '^(cvm|livemigrate|suspendresume|loadbalancer|guestagent|hostnamevalidation|imageboot|licensevalidation|network|security|hotattach|lssd|disk|packagevalidation|ssh|metadata|vmspec)$' \
492+ # -images 'projects/almalinux-dev-images-469421/global/images/family/almalinux-${{ env.version_major }}${{ inputs.arch == 'aarch64' && '-arm64' || '' }}' \
493+ # -parallel_stagger 10s -parallel_count 20
385494
386495 - name : Test ${{ inputs.type }} ${{ inputs.variant }} image
387496 # Skip testing for vagrant_virtualbox on GH runner because 'vugrant up' fails to connect to the newly created VM via ssh:
@@ -474,6 +583,15 @@ runs:
474583 name : ${{ env.IMAGE_NAME }}
475584 path : ${{ env.IMAGE_FILE }}
476585
586+ - uses : actions/upload-artifact@v4
587+ name : Store repo metadata as artifact
588+ id : repo-meta-artifact
589+ if : inputs.store_as_artifact == 'true'
590+ with :
591+ compression-level : 9
592+ name : ${{ env.IMAGE_NAME }}.repo-metadata.txt
593+ path : ${{ env.IMAGE_FILE }}.repo-metadata.txt
594+
477595 - uses : actions/upload-artifact@v4
478596 name : Store checksum as artifact
479597 id : checksum-artifact
@@ -488,7 +606,7 @@ runs:
488606 id : pkglist-artifact
489607 if : inputs.store_as_artifact == 'true' && env.got_pkgs_list == 'true'
490608 with :
491- compression-level : 1
609+ compression-level : 9
492610 name : ${{ env.IMAGE_NAME }}.txt
493611 path : ${{ env.IMAGE_FILE }}.txt
494612
0 commit comments