Build Ubuntu KDE VM Image #19
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Ubuntu KDE VM Image | |
on: | |
schedule: | |
- cron: '0 */6 * * *' # Every 6 hours | |
workflow_dispatch: | |
push: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Set up HashiCorp Packer | |
uses: hashicorp/setup-packer@v2 | |
- name: Install packages | |
run: | | |
sudo apt update | |
sudo apt purge -y man-db | |
sudo apt install -y qemu-system qemu-system-x86 qemu-system-gui qemu-utils cloud-image-utils | |
- name: Free Disk Space | |
uses: jlumbroso/[email protected] | |
- name: Create Build Directory | |
run: mkdir -p build | |
- name: Create Packer Template | |
run: | | |
cat <<EOF > build/ubuntu-kde.pkr.hcl | |
source "qemu" "ubuntu" { | |
iso_url = "https://releases.ubuntu.com/24.04/ubuntu-24.04.1-live-server-amd64.iso" | |
iso_checksum = "none" | |
disk_size = "20000" # 20GB | |
memory = 2048 | |
cpus = 2 | |
accelerator = "kvm" | |
display = "none" | |
headless = true | |
format = "qcow2" | |
output_directory = "output" | |
ssh_username = "ubuntu" | |
ssh_password = "changeMe" | |
shutdown_command = "echo changeMe | sudo -S shutdown -P now" | |
boot_command = [ | |
"<esc><esc><enter><wait>" | |
"/install/vmlinuz noapic" | |
" initrd=/install/initrd.gz" | |
" auto=true" | |
" priority=critical" | |
" hostname=ubuntu" | |
" passwd/user-fullname=Ubuntu" | |
" passwd/username=ubuntu" | |
" passwd/user-password=changeMe" | |
" passwd/user-password-again=changeMe" | |
" -- <enter>" | |
], | |
} | |
build { | |
name = "ubuntu-kde-vmware" | |
sources = ["source.qemu.ubuntu"] | |
provisioner "shell" { | |
inline = [ | |
"sudo apt update", | |
"sudo apt install -y kde-plasma-desktop", | |
"sudo systemctl set-default graphical.target", | |
"echo ubuntu:changeMe | sudo chpasswd", | |
"sudo chage -d 0 ubuntu" # Force password change after first login | |
] | |
} | |
} | |
EOF | |
- name: Build VMDK Image | |
run: | | |
packer plugins install github.com/hashicorp/qemu | |
# packer plugins install github.com/hashicorp/vmware | |
packer init build/ubuntu-kde.pkr.hcl | |
sudo chmod 666 /dev/kvm # very hacky approach but works | |
PACKER_LOG=1 packer build build/ubuntu-kde.pkr.hcl | |
- name: Upload VMDK Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ubuntu-kde-vmdk | |
path: build/output/* |