Skip to content

Commit 1921673

Browse files
allow override of image as a while and workflow creation
Signed-off-by: greg pereira <[email protected]>
1 parent 052009f commit 1921673

File tree

4 files changed

+110
-4
lines changed

4 files changed

+110
-4
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: Iso Builder Test Worfklow
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
paths:
8+
- './training/iso-builder/**'
9+
- '!training/iso-builder/README.md'
10+
- '.github/workflows/iso_builder_test.yaml'
11+
push:
12+
branches:
13+
- main
14+
paths:
15+
- './training/iso-builder/**'
16+
- '!training/iso-builder/README.md'
17+
- '.github/workflows/iso_builder_test.yaml'
18+
19+
workflow_dispatch:
20+
21+
env:
22+
REGISTRY: quay.io
23+
REGISTRY_ORG: ai-lab
24+
25+
jobs:
26+
iso-builder-build-and-test:
27+
if: "!contains(github.event.pull_request.labels.*.name, 'hold-tests')"
28+
strategy:
29+
matrix:
30+
include:
31+
- platforms: linux/amd64,linux/arm64
32+
parent_image_registry: quay.io
33+
parent_image_org: centos-bootc
34+
parent_image_name: centos-bootc
35+
parent_image_tag: stream9
36+
iso_image_name: iso-builder-centos-bootc
37+
iso_download_url: https://mirror.stream.centos.org/9-stream/BaseOS/x86_64/iso/CentOS-Stream-9-latest-x86_64-boot.iso
38+
iso_name: CentOS-Stream-9-latest-x86_64-boot.iso
39+
runs-on: ubuntu-22.04
40+
permissions:
41+
contents: read
42+
packages: write
43+
steps:
44+
45+
- name: Remove unnecessary files
46+
run: |
47+
sudo rm -rf /usr/share/dotnet
48+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
49+
50+
- uses: actions/[email protected]
51+
52+
- name: Install qemu dependency
53+
run: |
54+
sudo apt-get update
55+
sudo apt-get install -y qemu-user-static
56+
57+
- name: Generate an SSH key
58+
id: ssh-keygen
59+
run: |
60+
ssh-keygen -t ed25519 -C "[email protected]" -N "" -f id_rsa
61+
echo "sshpubkey=$(cat id_rsa.pub | xargs)" >> $GITHUB_OUTPUT
62+
63+
- name: Download the ISO
64+
working-directory: ./training/iso-builder/
65+
run: |
66+
make centos-iso-download
67+
68+
- name: Build Image
69+
id: build_image
70+
working-directory: ./training/iso-builder/
71+
run: |
72+
make image FROM=${{ matrix.parent_image_registry }}/${{ matrix.parent_image_org }}/${{ matrix.parent_image_name }}:${{ matrix.parent_image_tag }} IMAGE_NAME=${{ matrix.iso_image_name }} IMAGE_TAG=${{ matrix.parent_image_tag }}
73+
echo "embedded_image=$(echo '${{ matrix.parent_image_registry }}/${{ matrix.parent_image_org }}/${{ matrix.parent_image_name }}:${{ matrix.parent_image_tag }}' | xargs)" >> $GITHUB_OUTPUT
74+
echo "produced_image=$(echo '${{env.REGISTRY}}/${{env.REGISTRY_ORG}}/${{ matrix.iso_image_name }}:${{ matrix.parent_image_tag }}' | xargs)" >> $GITHUB_OUTPUT
75+
76+
- name: Run the Image
77+
working-directory: ./training/iso-builder/
78+
run: |
79+
make iso IMAGE=${{ steps.build_image.outputs.produced_image }} EMBED_IMAGE=${{ steps.build_image.outputs.embedded_image }} ORIGINAL_ISO="ISOs/${{ matrix.iso_name }}" SSHKEY="${{ steps.ssh-keygen.outputs.sshpubkey }}" CONTAINER_TOOL_EXTRA_ARGS=--pull=never
80+
81+
# - name: Setup tmate session
82+
# if: ${{ failure() }}
83+
# uses: mxschmitt/[email protected]
84+
# timeout-minutes: 10
85+
# with:
86+
# detached: false
87+
# limit-access-to-actor: true
88+
89+
# - name: Publish Job Results to Slack
90+
# id: slack
91+
# if: always()
92+
# uses: slackapi/[email protected]
93+
# with:
94+
# payload: |
95+
# {
96+
# "text": "${{ github.workflow }} workflow status: ${{ job.status }}\n${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
97+
# }
98+
# env:
99+
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ recipes/common/bin/*
1313
training/cloud/examples
1414
training/instructlab/instructlab
1515
vector_dbs/milvus/volumes/milvus/*
16+
training/iso-builder/ISOs/*
17+
!training/iso-builder/ISOs/.gitkeep

training/iso-builder/ISOs/.gitkeep

Whitespace-only changes.

training/iso-builder/Makefile

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,21 @@ REGISTRY ?= quay.io
44
REGISTRY_ORG ?= ai-lab
55
IMAGE_NAME ?= iso-builder
66
IMAGE_TAG ?= latest
7+
IMAGE ?= ${REGISTRY}/${REGISTRY_ORG}/${IMAGE_NAME}:${IMAGE_TAG}
78

89
CONTAINER_TOOL ?= podman
910
CONTAINER_TOOL_EXTRA_ARGS ?=
1011

1112
EMBED_IMAGE ?=
12-
ORIGINAL_ISO ?=
13+
ORIGINAL_ISO ?=
1314
SSHKEY ?=
1415
OUTPUT_DIR ?= ./iso
1516

16-
.PHONY: image iso
17+
.PHONY: image iso centos-iso-download
1718
image:
1819
"${CONTAINER_TOOL}" build \
1920
--file Containerfile \
20-
--tag "${REGISTRY}/${REGISTRY_ORG}/${IMAGE_NAME}:${IMAGE_TAG}" \
21+
--tag "${IMAGE}" \
2122
$(FROM:%=--from=%) \
2223
$(MODEL_REPO:%=--build-arg MODEL_REPO=%) \
2324
$(MODEL_PATH:%=--build-arg MODEL_PATH=%) \
@@ -44,9 +45,13 @@ iso:
4445
--volume $(shell readlink -f ${ORIGINAL_ISO}):/root/original.iso:ro \
4546
--volume ${OUTPUT_DIR}:/output \
4647
--volume $(shell ${CONTAINER_TOOL} system info --format json | jq -r '.store.graphRoot'):/var/lib/containers/storage \
47-
"${REGISTRY}/${REGISTRY_ORG}/${IMAGE_NAME}:${IMAGE_TAG}" \
48+
${CONTAINER_TOOL_EXTRA_ARGS} \
49+
"${IMAGE}" \
4850
"${EMBED_IMAGE}" \
4951
/root/ks.template \
5052
"${SSHKEY}" \
5153
/root/original.iso \
5254
"/output/$(shell basename ${EMBED_IMAGE}).iso"
55+
56+
centos-iso-download:
57+
curl -sL https://mirror.stream.centos.org/9-stream/BaseOS/x86_64/iso/CentOS-Stream-9-latest-x86_64-boot.iso -o ISOs/CentOS-Stream-9-latest-x86_64-boot.iso

0 commit comments

Comments
 (0)