name: Create and publish an ISO on: push: branches: - 'main' tags: - 'v*' pull_request: # Test Values env: ARCH: 'x86_64' IMAGE_NAME: 'base' IMAGE_REPO: 'quay.io/fedora-ostree-desktops' VERSION: '39' VARIANT: 'Server' jobs: build-container: runs-on: ubuntu-latest permissions: contents: read packages: write steps: - name: Checkout repo uses: actions/checkout@v4 - name: Docker meta id: meta uses: docker/metadata-action@v5 with: images: | ghcr.io/${{ github.repository }} tags: | type=ref,event=branch type=ref,event=pr type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} - name: Buildah Build id: build-image uses: redhat-actions/buildah-build@v2 with: containerfiles: Containerfile tags: ${{ steps.meta.outputs.tags }} - name: Push image uses: redhat-actions/push-to-registry@v2 with: image: ${{ steps.build-image.outputs.image }} tags: ${{ steps.build-image.outputs.tags }} username: ${{ github.actor }} password: ${{ github.token }} build-and-push-iso: runs-on: ubuntu-latest needs: - build-container permissions: contents: read packages: write steps: - name: Checkout repo uses: actions/checkout@v4 - name: Lowercase Registry id: registry_case uses: ASzc/change-string-case-action@v6 with: string: ${{ env.IMAGE_REPO }} - name: Get image version id: meta uses: docker/metadata-action@v5 with: tags: | type=ref,event=branch type=ref,event=pr - name: Build ISO with new container uses: ./ with: arch: ${{ env.ARCH}} image_name: ${{ env.IMAGE_NAME}} image_repo: ${{ env.IMAGE_REPO}} version: ${{ env.VERSION }} variant: ${{ env.VARIANT }} - name: Rename ISO run: | mv build/deploy.iso build/${{ env.IMAGE_NAME }}-${{ env.VERSION }}.iso - name: Upload ISO as artifact id: upload uses: actions/upload-artifact@v4 with: name: ${{ env.IMAGE_NAME }}-${{ env.VERSION }}.iso path: build/*.iso if-no-files-found: error retention-days: 0 compression-level: 0 overwrite: true test-qemu: runs-on: ubuntu-latest needs: - build-and-push-iso permissions: contents: read packages: write steps: - name: Ensure qemu is installed run: | sudo apt-get update sudo apt-get install -y qemu qemu-utils xorriso unzip qemu-system-x86 netcat isomd5sum - name: Create disk run: | qemu-img create -f qcow2 disk.qcow2 50G - name: Download generated ISO uses: actions/download-artifact@v4 with: name: ${{ env.IMAGE_NAME }}-${{ env.VERSION }}.iso - name: Verify ISO run: checkisomd5 ${{ env.IMAGE_NAME }}-${{ env.VERSION }}.iso - name: Add Kickstart and Grub options to ISO run: | sudo mkdir /mnt/iso sudo mount -o loop ${{ env.IMAGE_NAME }}-${{ env.VERSION }}.iso /mnt/iso cp /mnt/iso/boot/grub2/grub.cfg grub.cfg sed -i 's/quiet/console=ttyS0,115200n8 inst.ks=cdrom:\/ks.cfg/' grub.cfg sed -i 's/set default="1"/set default="0"/' grub.cfg cat << EOF > ks.cfg lang en_US.UTF-8 keyboard us timezone Americas/New_York zerombr clearpart --all --initlabel autopart reboot user --name=core --groups=wheel --password=foobar %include /usr/share/anaconda/interactive-defaults.ks EOF xorriso -dialog on << EOF -indev base-39.iso -outdev test.iso -boot_image any replay -map ks.cfg ks.cfg -chmod 0444 ks.cfg -map grub.cfg boot/grub2/grub.cfg -end EOF - name: Install the test VM run: | timout 30m qemu-system-x86_64 -name "Anaconda" -boot d -m 4096 -cpu qemu64 -display none -cdrom test.iso -smp 2 -drive file=disk.qcow2 -serial telnet:localhost:4321,server,nowait & QEMU_PID=$! echo "PID: $QEMU_PID" timeout 1m bash -c "while ! (echo > /dev/tcp/127.0.0.1/4321); do sleep 0.1; done" (nc localhost 4321 | tee vm.stdout) & wait $QEMU_PID - name: Start the test VM run: | qemu-system-x86_64 -name "Anaconda" -boot c -m 4096 -cpu qemu64 -display none -smp 2 -drive file=disk.qcow2 -serial telnet:localhost:4321,server,nowait & export QEMU_PID=$! echo "PID: $QEMU_PID" timeout 1m bash -c "while ! (echo > /dev/tcp/127.0.0.1/4321); do sleep 0.1; done" (nc localhost 4321 | tee vm.stdout) & timeout 30m bash -c "while ! (grep 'login:' vm.stdout); do sleep 1; done" echo "VM ready for tests"