mirror of
https://github.com/JasonN3/build-container-installer.git
synced 2025-12-25 19:07:54 +01:00
180 lines
4.7 KiB
YAML
180 lines
4.7 KiB
YAML
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:
|
|
check-changes:
|
|
name: Check Changes
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
container: ${{ steps.changes.outputs.container }}
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
|
|
- uses: dorny/paths-filter@v2
|
|
id: changes
|
|
with:
|
|
filters: |
|
|
container:
|
|
- 'Containerfile'
|
|
- '/lorax_templates/**'
|
|
- '/xorriso/**'
|
|
- '/Makefile'
|
|
- '/entrypoint.sh'
|
|
|
|
build-container:
|
|
runs-on: ubuntu-latest
|
|
if: needs.check-changes.outputs.container == 'true'
|
|
needs:
|
|
- check-changes
|
|
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:
|
|
- check-changes
|
|
- build-container
|
|
if: always() && (needs.build-container.result == 'success' || needs.build-container.result == 'skipped')
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
outputs:
|
|
artifact_url: ${{ steps.upload.outputs.artifact-url }}
|
|
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
|
|
if: needs.check-changes.outputs.container == 'true'
|
|
uses: ./
|
|
with:
|
|
arch: ${{ env.ARCH}}
|
|
image_name: ${{ env.IMAGE_NAME}}
|
|
image_repo: ${{ env.IMAGE_REPO}}
|
|
version: ${{ env.VERSION }}
|
|
variant: ${{ env.VARIANT }}
|
|
action_version: ${{ steps.meta.outputs.tags }}
|
|
|
|
- name: Build ISO with latest container
|
|
if: needs.check-changes.outputs.container == 'false'
|
|
uses: ./
|
|
with:
|
|
arch: ${{ env.ARCH}}
|
|
image_name: ${{ env.IMAGE_NAME}}
|
|
image_repo: ${{ env.IMAGE_REPO}}
|
|
version: ${{ env.VERSION }}
|
|
variant: ${{ env.VARIANT }}
|
|
action_version: ${{ steps.meta.outputs.tags || 'latest' }}
|
|
|
|
- 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: |
|
|
apt-get update
|
|
apt-get install -y qemu qemu-utils xorriso unzip
|
|
|
|
- name: Create disk
|
|
run: |
|
|
qemu-img create -f qcow2 disk.qcow2 50G
|
|
|
|
- name: Add anaconda.ks to ISO
|
|
run: |
|
|
wget ${{ needs.build-and-push-iso.outputs.artifact_url }}
|
|
ls
|
|
unzip *.zip
|
|
cat << EOF > ks.cfg
|
|
|
|
EOF
|
|
xorriso -dialog on << EOF
|
|
-indev ${{ env.IMAGE_NAME }}-${{ env.VERSION }}.iso
|
|
-outdev test.iso
|
|
-map ks.cfg ks.cfg
|
|
-chmod 0444 ks.cfg
|
|
-end
|
|
EOF
|
|
|
|
#- name: Start a VM
|
|
# run: |
|
|
# qemu-system-x86_64 --name "Anaconda" -m 4096 -cpu host -cdrom test.iso -drive file=disk.qcow2
|