Files
vms/.github/workflows/build.yml
T

62 lines
1.9 KiB
YAML

name: Build the boxes
"on":
workflow_dispatch:
jobs:
collect:
name: Discover distros
runs-on: ubuntu-latest
outputs:
distros: ${{ steps.distros.outputs.distros }}
steps:
- uses: actions/checkout@v3
- name: Discover boxes
id: distros
run: |-
set -eo pipefail
distros=$(ls distros/*.hcl{,.sh} | jq -cRs 'split("\n") | [ .[] | if length > 0 then . else empty end ]')
echo "::set-output name=distros::${distros}"
build:
name: Build box
runs-on: ubuntu-latest
needs:
- collect
strategy:
fail-fast: false
matrix:
distro: ${{ fromJson( needs.collect.outputs.distros ) }}
needs_timeout:
- distros/ubuntu-20.04-x86_64.pkrvars.hcl
steps:
- name: Checkout project
uses: actions/checkout@v3
with:
submodules: recursive
- uses: ./.github/actions/setup
with:
ansible: true
- uses: ./.github/actions/install_packer
- uses: greg-hellings/make-space@main
- name: modify build timeouts, if necessary
if: contains(matrix.needs_timeout, matrix.distro)
shell: bash
run: ./modify_timeout.sh "${{ matrix.distro }}"
- name: Run generator, if necessary
if: endsWith(matrix.distro, '.sh')
run: "${{ matrix.distro }}"
- name: try build
shell: bash
run: |
set -e
# Strip .sh if it is a dynamic one
file="$(printf "${{ matrix.distro }}" | sed -E -e 's/^(.*).sh$/\1/')"
# Add a retry in case something bogus like a network failure happens
until packer build -var-file="${file}" -var "qemu_accelerator=tcg" -except=upload sources; do
sleep 1
done
env:
VAGRANT_CLOUD_TOKEN: ${{ secrets.VAGRANT_CLOUD_TOKEN }}
PACKER_LOG: ${{ contains(matrix.needs_timeout, matrix.distro) && '1' || '1' }}