From 4a2f8ed26f366fb1e9c4566e186fa295e3411777 Mon Sep 17 00:00:00 2001 From: Danny Bessems Date: Wed, 30 Jul 2025 19:44:24 +1000 Subject: [PATCH] build: Upload image artifact to repository/hypervisor --- .gitea/workflows/actions.yaml | 49 +++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/.gitea/workflows/actions.yaml b/.gitea/workflows/actions.yaml index 696f59d..9c09b81 100644 --- a/.gitea/workflows/actions.yaml +++ b/.gitea/workflows/actions.yaml @@ -29,8 +29,6 @@ jobs: --analyzeCommits @semantic-release/commit-analyzer \ --verifyRelease @semantic-release/exec \ --verifyReleaseCmd 'echo "version=${nextRelease.version}" >> $GITHUB_OUTPUT' - env: - GIT_CREDENTIALS: ${{ secrets.GIT_USERNAME }}:${{ secrets.GIT_APIKEY }} - name: Assert semantic release output run: | [[ -z "${{ steps.sem_rel.outputs.version }}" ]] && { @@ -67,10 +65,10 @@ jobs: 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_rke2_${{ needs.semrel_dryrun.outputs.version }}.img \ + -o ubuntu-vm/ubuntu-24.04.2-rke2-v${{ needs.semrel_dryrun.outputs.version }}.img \ -u ${{ secrets.REPO_USERNAME }}:${{ secrets.REPO_PASSWORD }} - qemu-img resize ubuntu-vm/ubuntu_rke2_${{ needs.semrel_dryrun.outputs.version }}.img +5G + qemu-img resize ubuntu-vm/ubuntu-24.04.2-rke2-v${{ needs.semrel_dryrun.outputs.version }}.img +5G - name: Generate seed ISO run: | envsubst < cloud-init/user-data.template > cloud-init/user-data @@ -82,8 +80,8 @@ jobs: -rock \ cloud-init/meta-data cloud-init/user-data env: - ROOT_HASHED_PASSWORD: ${{ secrets.ROOT_HASHED_PASSWORD }} - PUBLIC_SSHKEY: ${{ secrets.PUBLIC_SSHKEY }} + ROOT_HASHED_PASSWORD: ${{ secrets.VM_ROOT_HASHED_PASSWORD }} + PUBLIC_SSHKEY: ${{ secrets.VM_PUBLIC_SSHKEY }} - name: Provision template virtual machine run: | [ -e /dev/kvm ] && kvm_flag="-enable-kvm" || kvm_flag="" @@ -93,7 +91,7 @@ jobs: -m 3072 \ -smp 2 \ -cpu host \ - -drive file=ubuntu-vm/ubuntu_rke2_${{ needs.semrel_dryrun.outputs.version }}.img,if=virtio,format=qcow2 \ + -drive file=ubuntu-vm/ubuntu-24.04.2-rke2-v${{ needs.semrel_dryrun.outputs.version }}.img,if=virtio,format=qcow2 \ -drive file=ubuntu-vm/seed.iso,format=raw,media=cdrom \ -nographic \ -net nic \ @@ -102,10 +100,45 @@ jobs: -chardev socket,path=qga.sock,server=on,wait=off,id=qga0 \ -device virtserialport,chardev=qga0,name=org.qemu.guest_agent.0 - if ! guestfish --ro -a ubuntu-vm/ubuntu_rke2_${{ needs.semrel_dryrun.outputs.version }}.img -i stat /var/log/template-generation-success; then + if ! guestfish --ro -a ubuntu-vm/ubuntu-24.04.2-rke2-v${{ needs.semrel_dryrun.outputs.version }}.img -i stat /var/log/template-generation-success; then echo "VM provisioning encountered errors - exiting" exit 1 fi + - name: Compress image file + run: | + virt-sparsify --compress \ + ubuntu-vm/ubuntu-24.04.2-rke2-v${{ needs.semrel_dryrun.outputs.version }}.img \ + ubuntu-vm/ubuntu-24.04.2-rke2-v${{ needs.semrel_dryrun.outputs.version }}-compacted.img + - name: Upload image file + run: | + REPO_TOKEN=$(curl -fsSL -X POST \ + http://filebrowser.filebrowser.svc.cluster.local:80/api/login \ + -H "Content-Type: application/json" \ + -d '{"username": "admin", "password": "${{ secrets.REPO_PASSWORD }}"}' \ + ) + + curl -fsSL -X POST \ + http://filebrowser.filebrowser.svc.cluster.local:80/api/resources/rel/ubuntu-24.04.2-rke2-v${{ needs.semrel_dryrun.outputs.version }}.img?override=true \ + --header "X-Auth: $REPO_TOKEN" \ + --upload-file "ubuntu-vm/ubuntu-24.04.2-rke2-v${{ needs.semrel_dryrun.outputs.version }}.img" + + # curl -ksS -X POST "https://lab-hv-vip.bessems.lan/v1/harvesterhci.io.virtualmachineimages" \ + # -H "Authorization: Bearer ${{ secrets.HV_TOKEN }}" \ + # -H "Content-Type: application/json" \ + # -d @- <