Skip to content

Add VirtualBox and Vagrant #159

Add VirtualBox and Vagrant

Add VirtualBox and Vagrant #159

Workflow file for this run

name: vm-provision
on:
push:
branches:
- main
- 'testing/**'
- 'feature/**'
- 'hotfix/**'
# Run pipeline for release tags
tags:
- 'v*.*.*'
schedule:
# Weekly builds on Monday morning 4:42
# Github doc:
# "The schedule event can be delayed during periods of high loads of GitHub Actions workflow runs.
# High load times include the start of every hour.
# To decrease the chance of delay, schedule your workflow to run at a different time of the hour."
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
- cron: '42 4 * * 1'
jobs:
vagrant-provision:
runs-on: ubuntu-latest
steps:
- name: enable kvm group perms
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: install prerequisites
run: |
sudo apt-get install -y virtualbox
sudo apt-get install -y vagrant
- name: clean up old VMs
run: |
vboxmanage list vms | \
grep -o -P '(?<={).*(?=})' | \
while read line ; do vboxmanage unregistervm $line --delete ; done
- uses: actions/checkout@v4
- name: show Vagrant version
run: vagrant --version
- name: run vagrant up
run: |
vagrant up
echo "=> Vagrant run finished."
env:
GITHUB_TOKEN: ${{ github.token }}
- name: export virtualbox VM
run: |
vagrant halt
vboxmanage export emoflon -o emoflon.ovf
sed -i -e '/<BIOS>/,/<\/BIOS>/d' emoflon.ovf
sed -i -e '/<RemoteDisplay enabled="true">/,/<\/RemoteDisplay>/d' emoflon.ovf
tar -cvf emoflon.ova emoflon.ovf emoflon-disk001.vmdk
rm -rf emoflon.ovf emoflon-disk001.vmdk
- name: upload artifact
uses: actions/upload-artifact@v4
with:
name: emoflon-ova
path: emoflon.ova
# Create a release if running on tag
create-release:
needs: [vagrant-provision]
runs-on: ubuntu-20.04
# Only run on pushed tags (and explicitely ignore scheduled runs)
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') && github.event_name != 'schedule'
steps:
- name: collect artifacts
uses: actions/download-artifact@master
- name: create splitted ZIP archive
run: |
sudo apt-get install -yq zip
zip -r -s 1990m emoflon-vm.zip emoflon-ova/emoflon.ova
# Due to a bug in the release action, we have to upload all artifacts step-by-step
# https://github.com/softprops/action-gh-release/issues/243
- name: release emoflon-vm (1)
uses: softprops/action-gh-release@v1
with:
body: "The VM archive can not be directly added to this release because of the size limitation of 2GB per file. Please download the splitted ZIP archive and extract it manually."
files: emoflon-vm.zip
- name: release emoflon-vm (2)
uses: softprops/action-gh-release@v1
with:
body: "The VM archive can not be directly added to this release because of the size limitation of 2GB per file. Please download the splitted ZIP archive and extract it manually."
files: emoflon-vm.z01
- name: release emoflon-vm (3)
uses: softprops/action-gh-release@v1
with:
body: "The VM archive can not be directly added to this release because of the size limitation of 2GB per file. Please download the splitted ZIP archive and extract it manually."
files: emoflon-vm.z02