vm-provision #210
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: 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: | |
# Running on self-hosted system(s), because GitHub-hosted action runners did break too often. | |
# https://github.com/actions/runner-images/issues/433 | |
runs-on: | |
group: Default | |
labels: [self-hosted, Linux, X64] | |
steps: | |
- name: clean up old VirtualBox VMs | |
run: | | |
vboxmanage list vms | \ | |
grep -o -P '(?<={).*(?=})' | \ | |
while read line ; do vboxmanage unregistervm $line --delete ; done | |
- name: clean up old Vagrant artifacts | |
run: | | |
vagrant destroy emoflon || true | |
vagrant box remove gusztavvargadr/xubuntu-desktop-2404-lts || true | |
# https://stackoverflow.com/a/71346341 | |
- name: clean up old GitHub Actions runner build folder | |
run: | | |
ls -la ./ | |
rm -rf ./* || true | |
rm -rf ./.??* || true | |
ls -la ./ | |
- 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@v4 | |
- 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@v2 | |
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@v2 | |
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@v2 | |
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 | |
- name: release emoflon-vm (4) | |
uses: softprops/action-gh-release@v2 | |
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.z03 |