runner!
All checks were successful
Hello World / test (push) Successful in 4s

This commit is contained in:
plasmagoat 2025-06-07 01:37:49 +02:00
parent 3658fb2285
commit f49c705d36
3 changed files with 34 additions and 24 deletions

View file

@ -1,37 +1,42 @@
name: "Build NixOS Image and Upload to Proxmox" name: Build and Upload NixOS Image
on: on:
workflow_dispatch: # Manual trigger workflow_dispatch:
jobs: jobs:
build-upload: build:
runs-on: self-hosted runs-on: [nixos]
defaults:
run:
working-directory: nixos
steps: steps:
- name: Checkout flake - name: Checkout repo
uses: actions/checkout@v3 uses: actions/checkout@v3
- name: Set up Nix - name: Build NixOS image
uses: cachix/install-nix-action@v22 run: nix build .#nixosImage
with:
extra_nix_config: |
experimental-features = nix-command flakes
- name: Build Proxmox image - name: Upload image to Proxmox
run: |
nix build .#base
- name: Upload to Proxmox
env: env:
PROXMOX_HOST: ${{ secrets.PROXMOX_HOST }} SSH_KEY: ${{ secrets.PROXMOX_SSH_KEY }}
PROXMOX_USER: ${{ secrets.PROXMOX_USER }} PROXMOX_USER: root
PROXMOX_PASSWORD: ${{ secrets.PROXMOX_PASSWORD }} PROXMOX_HOST: 192.168.1.205
run: | run: |
scp result/*.vma.zst "$PROXMOX_USER@$PROXMOX_HOST:/var/lib/vz/dump/" mkdir -p ~/.ssh
echo "$SSH_KEY" > ~/.ssh/id_proxmox
chmod 600 ~/.ssh/id_proxmox
export SSH="ssh -i ~/.ssh/id_proxmox -o StrictHostKeyChecking=no"
export SCP="scp -i ~/.ssh/id_proxmox -o StrictHostKeyChecking=no"
- name: Replace template on Proxmox IMAGE=$(find result/ -name '*.vma.zst' | head -n 1)
run: | NAME=$(basename "$IMAGE")
ssh "$PROXMOX_USER@$PROXMOX_HOST" "
qmrestore /var/lib/vz/dump/nixos-base.vma.zst 9000 --unique=true && echo "Uploading $IMAGE to $PROXMOX_HOST..."
qm set 9000 --name nixos-base --cores 2 --memory 2048 && $SCP "$IMAGE" "$PROXMOX_USER@$PROXMOX_HOST:/var/lib/vz/dump/"
echo "Restoring and converting to template..."
$SSH "$PROXMOX_USER@$PROXMOX_HOST" "
qmrestore /var/lib/vz/dump/$NAME 9000 --unique --replace &&
qm template 9000 qm template 9000
" "

View file

@ -0,0 +1,4 @@
```bash
ssh-keygen -t ed25519 -C "forgejo-runner" -f forgejo-image-uploader
```

View file

@ -20,6 +20,7 @@
# "ubuntu-22.04:docker://node:16-bullseye" # "ubuntu-22.04:docker://node:16-bullseye"
# "ubuntu-20.04:docker://node:16-bullseye" # "ubuntu-20.04:docker://node:16-bullseye"
# "ubuntu-18.04:docker://node:16-buster" # "ubuntu-18.04:docker://node:16-buster"
"nixos:docker://cachix/nix-build-action"
## optionally provide native execution on the host: ## optionally provide native execution on the host:
# "native:host" # "native:host"
]; ];