build: Assert successful completion of cloud-init
All checks were successful
build-image / Build image (push) Successful in 9m20s

This commit is contained in:
2025-07-29 13:20:41 +10:00
parent c2f4b83102
commit 532ef878de
2 changed files with 34 additions and 21 deletions

View File

@ -50,23 +50,33 @@ jobs:
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Create folder structure
- name: Set up build container
run: |
apt-get update && \
apt-get install -y \
gettext \
genisoimage \
libguestfs-tools \
linux-image-generic \
linux-modules-extra-$(uname -r) \
linux-headers-generic \
qemu-system-x86 \
qemu-utils \
supermin
mkdir -p \
ubuntu-vm
- name: Download source Ubuntu iso
$PWD/ubuntu-vm \
/mnt/vmimage
- name: Retrieve source Ubuntu image
run: |
curl -L \
https://sn.itch.fyi/Repository/iso/Canonical/Ubuntu%20Server%2024.04/ubuntu-24.04-server-cloudimg-amd64.img \
-o ubuntu-vm/ubuntu.img \
-u ${{ secrets.REPO_USERNAME }}:${{ secrets.REPO_PASSWORD }}
qemu-img resize ubuntu-vm/ubuntu.img +5G
- name: Generate seed ISO
run: |
apt-get update && \
apt-get install -y \
gettext \
genisoimage
envsubst < cloud-init/user-data.template > cloud-init/user-data
genisoimage \
@ -78,15 +88,8 @@ jobs:
env:
ROOT_HASHED_PASSWORD: ${{ secrets.ROOT_HASHED_PASSWORD }}
PUBLIC_SSHKEY: ${{ secrets.PUBLIC_SSHKEY }}
- name: Start virtual machine
- name: Provision template virtual machine
run: |
apt-get update && \
apt-get install -y \
qemu-system-x86 \
qemu-utils
qemu-img resize ubuntu-vm/ubuntu.img +5G
[ -e /dev/kvm ] && kvm_flag="-enable-kvm" || kvm_flag=""
qemu-system-x86_64 \
@ -98,11 +101,15 @@ jobs:
-drive file=ubuntu-vm/seed.iso,format=raw,media=cdrom \
-nographic \
-net nic \
-net user
-net user \
-device virtio-serial-pci,id=virtio-serial0 \
-chardev socket,path=qga.sock,server=on,wait=off,id=qga0 \
-device virtserialport,chardev=qga0,name=org.qemu.guest_agent.0
qemu-img convert -O qcow2 ubuntu-vm/ubuntu.img ubuntu-vm/ubuntu-compacted.img
ls -lash ubuntu-vm
if ! guestfish --ro -a ubuntu-vm/ubuntu.img -i stat /var/log/template-generation-success; then
echo "VM provisioning encountered errors - exiting"
exit 1
fi
# semrel:
# name: Semantic Release

View File

@ -18,7 +18,8 @@ runcmd:
- truncate -s 0 /etc/hostname /etc/machine-id
- rm -f /etc/ssh/ssh_host_* /var/lib/dbus/machine-id
- ln -s /etc/machine-id /var/lib/dbus/machine-id
- poweroff
- echo "TEMPLATE_GENERATION_SUCCESS" | tee /var/log/template-generation-success
- sync
disable_root: false
users:
@ -30,3 +31,8 @@ users:
- ${PUBLIC_SSHKEY}
ssh_authorized_keys:
- ${PUBLIC_SSHKEY}
power_state:
delay: now
mode: poweroff
condition: true