This commit is contained in:
plasmagoat 2025-06-08 12:31:56 +02:00
parent f49dc3292c
commit 259d4fb084

View file

@ -9,6 +9,7 @@ on:
jobs: jobs:
build: build:
runs-on: nixos-latest runs-on: nixos-latest
name: Build NixOS Image
env: env:
PROXMOX_HOST: 192.168.1.205 PROXMOX_HOST: 192.168.1.205
PROXMOX_USER: forgejo-runner PROXMOX_USER: forgejo-runner
@ -78,6 +79,7 @@ jobs:
path: ${{ steps.build.outputs.image }} path: ${{ steps.build.outputs.image }}
release: release:
name: Create New Release
needs: build needs: build
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: success() if: success()
@ -96,4 +98,30 @@ jobs:
direction: upload direction: upload
release-notes: | release-notes: |
This release contains the NixOS base image for Proxmox labeled `${{ steps.version.outputs.tag }}`. This release contains the NixOS base image for Proxmox labeled `${{ steps.version.outputs.tag }}`.
release-dir: ${{ steps.artifact.outputs.download-path }} # release-dir: ${{ steps.artifact.outputs.download-path }}
- name: Upload image to Proxmox and manage templates
run: |
set -e
ls
FOLDER="${{ steps.artifact.outputs.download-path }}"
IMAGE_PATH=$(find "$FOLDER" -maxdepth 1 -type f -name '*.vma.zst' | head -n 1)
IMAGE=$(basename "$FULL_PATH")
REMOTE_NAME="nixos-base-image-${{ steps.version.outputs.tag}}.vma.zst"
REMOTE_PATH="/var/lib/vz/dump/$REMOTE_NAME"
echo "Uploading $IMAGE to Proxmox as $REMOTE_NAME"
scp $IMAGE_PATH $PROXMOX_USER@$PROXMOX_HOST:$REMOTE_PATH
echo "Restoring as VMID $TEMPLATE_VMID"
ssh $PROXMOX_USER@$PROXMOX_HOST "
qm destroy $TEMPLATE_VMID --purge || true
qmrestore $REMOTE_PATH $TEMPLATE_VMID --unique
qm template $TEMPLATE_VMID
echo 'Cloning to $LATEST_TEMPLATE_VMID as latest'
qm destroy $LATEST_TEMPLATE_VMID --purge || true
qm clone $TEMPLATE_VMID $LATEST_TEMPLATE_VMID --name nixos-base-latest
qm template $TEMPLATE_VMID
"