Skip to content

Commit

Permalink
infra: Build also live images
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirSlavik committed Aug 23, 2023
1 parent e0c54b0 commit e2598c9
Show file tree
Hide file tree
Showing 2 changed files with 195 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,21 @@
# THIS FILE IS GENERATED FROM A TEMPLATE
# DO NOT EDIT THIS FILE MANUALLY!
# ======================================
# The template is located in: build-boot-iso.yml.j2
# The template is located in: build-iso.yml.j2

# Build a boot.iso from a PR triggered by a "/boot-iso" comment or manually.
# You can use the --webui option to build a webui boot.iso instead
# Build a bootable image from a PR triggered by a "/build-iso" comment or manually.
#
# Choose type of the image with these options:
# --boot.iso
# --live
#
# If none of these is present, --boot-iso is assumed.
# If both are present, both variants are built.
#
# To use webui on boot.iso, add also:
# --webui

name: Build boot.iso
name: Build ISO image
on:
issue_comment:
types: [created]
Expand All @@ -22,7 +31,7 @@ permissions:

jobs:
pr-info:
if: github.event_name == 'workflow_dispatch' || startsWith(github.event.comment.body, '/boot-iso')
if: github.event_name == 'workflow_dispatch' || startsWith(github.event.comment.body, '/build-iso')
runs-on: ubuntu-latest
steps:
- name: Query comment author repository permissions
Expand Down Expand Up @@ -59,9 +68,13 @@ jobs:
env:
BODY: ${{ github.event.comment.body }}
run: |
# extract first line and cut out the "/boot-iso" first word
# extract first line and cut out the "/build-iso" first word
ARGS=$(echo "$BODY" | sed -n '1 s/^[^ ]* *//p' | sed 's/[[:space:]]*$//')
echo "arguments are: $ARGS"
if ! [[ "$ARGS" == *"--boot.iso"* || "$ARGS" == *"--live"* ]] ; then
ARGS="$ARGS --boot.iso"
echo "adding implicit --boot.iso, arguments now are: $ARGS"
fi
echo "args=${ARGS}" >> $GITHUB_OUTPUT
- name: Construct image description
Expand Down Expand Up @@ -112,10 +125,10 @@ jobs:
args: ${{ steps.parse_args.outputs.args }}
image_description: ${{ steps.image_description.outputs.image_description }}

run:
boot-iso:
needs: pr-info
# only do this for Fedora for now; once we have RHEL 8/9 boot.iso builds working, also support these
if: needs.pr-info.outputs.allowed_user == 'true'
if: needs.pr-info.outputs.allowed_user == 'true' && contains(needs.pr-info.outputs.args, '--boot.iso')
runs-on: [self-hosted, kstest]
timeout-minutes: 300
env:
Expand Down Expand Up @@ -158,7 +171,7 @@ jobs:
mkdir -p ./anaconda_rpms/
cp -av ./result/build/01-rpm-build/*.rpm ./anaconda_rpms/
- name: Build the boot.iso
- name: Build the ISO image
run: |
mkdir -p images
if [[ "${{ needs.pr-info.outputs.args }}" == *"--webui"* ]] ; then
Expand All @@ -184,7 +197,7 @@ jobs:
- name: Upload image
uses: actions/upload-artifact@v3
with:
name: image ${{ needs.pr-info.outputs.image_description }}
name: boot.iso image for ${{ needs.pr-info.outputs.image_description }}
path: |
images/*.iso
Expand All @@ -211,3 +224,78 @@ jobs:
target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

live-cd:
needs: pr-info
if: needs.pr-info.outputs.allowed_user == 'true' && contains(needs.pr-info.outputs.args, '--live')
runs-on: [self-hosted, kstest]
timeout-minutes: 300
env:
STATUS_NAME: live-cd
CONTAINER_TAG: 'lorax'
ISO_BUILD_CONTAINER_NAME: 'quay.io/rhinstaller/anaconda-live-iso-creator'
steps:
# we post statuses manually as this does not run from a pull_request event
# https://developer.github.com/v3/repos/statuses/#create-a-status
- name: Create in-progress status
uses: octokit/[email protected]
with:
route: 'POST /repos/${{ github.repository }}/statuses/${{ needs.pr-info.outputs.sha }}'
context: '${{ env.STATUS_NAME }} ${{ needs.pr-info.outputs.launch_args }}'
state: pending
target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Clone repository
uses: actions/checkout@v3
with:
ref: ${{ needs.pr-info.outputs.sha }}
fetch-depth: 0

- name: Build anaconda-rpm container (for RPM build)
run: |
# set static tag to avoid complications when looking what tag is used
make -f ./Makefile.am anaconda-rpm-build CI_TAG=$CONTAINER_TAG
- name: Build Anaconda RPM files
run: |
# output of the build will be stored in ./result/build/01-rpm-build/*.rpm
make -f ./Makefile.am container-rpms-scratch CI_TAG=$CONTAINER_TAG
- name: Build the ISO image
run: |
mkdir -p images
make -f Makefile.am container-live-iso-build
mv result/iso/Fedora-Workstation.iso "images/${{ needs.pr-info.outputs.image_description }}-Fedora-Workstation.iso"
- name: Make artefacts created by sudo cleanable
if: always()
run:
sudo chown -R github:github .

- name: Collect logs
if: always()
uses: actions/upload-artifact@v3
with:
name: 'logs'
path: |
images/*.log
- name: Upload image artifacts
uses: actions/upload-artifact@v3
with:
name: live image for ${{ needs.pr-info.outputs.image_description }}
path: |
images/*.iso
- name: Set result status
if: always()
uses: octokit/[email protected]
with:
route: 'POST /repos/${{ github.repository }}/statuses/${{ needs.pr-info.outputs.sha }}'
context: '${{ env.STATUS_NAME }} ${{ needs.pr-info.outputs.launch_args }}'
state: ${{ job.status }}
target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
{% if distro_release == "rawhide" %}
# Build a boot.iso from a PR triggered by a "/boot-iso" comment or manually.
# You can use the --webui option to build a webui boot.iso instead
# Build a bootable image from a PR triggered by a "/build-iso" comment or manually.
#
# Choose type of the image with these options:
# --boot.iso
# --live
#
# If none of these is present, --boot-iso is assumed.
# If both are present, both variants are built.
#
# To use webui on boot.iso, add also:
# --webui

name: Build boot.iso
name: Build ISO image
on:
issue_comment:
types: [created]
Expand All @@ -16,7 +25,7 @@ permissions:

jobs:
pr-info:
if: github.event_name == 'workflow_dispatch' || startsWith(github.event.comment.body, '/boot-iso')
if: github.event_name == 'workflow_dispatch' || startsWith(github.event.comment.body, '/build-iso')
runs-on: ubuntu-latest
steps:
- name: Query comment author repository permissions
Expand Down Expand Up @@ -53,9 +62,13 @@ jobs:
env:
BODY: ${{ github.event.comment.body }}
run: |
# extract first line and cut out the "/boot-iso" first word
# extract first line and cut out the "/build-iso" first word
ARGS=$(echo "$BODY" | sed -n '1 s/^[^ ]* *//p' | sed 's/[[:space:]]*$//')
echo "arguments are: $ARGS"
if ! [[ "$ARGS" == *"--boot.iso"* || "$ARGS" == *"--live"* ]] ; then
ARGS="$ARGS --boot.iso"
echo "adding implicit --boot.iso, arguments now are: $ARGS"
fi
echo "args=${ARGS}" >> $GITHUB_OUTPUT

- name: Construct image description
Expand Down Expand Up @@ -106,10 +119,10 @@ jobs:
args: ${{ steps.parse_args.outputs.args }}
image_description: ${{ steps.image_description.outputs.image_description }}

run:
boot-iso:
needs: pr-info
# only do this for Fedora for now; once we have RHEL 8/9 boot.iso builds working, also support these
if: needs.pr-info.outputs.allowed_user == 'true'
if: needs.pr-info.outputs.allowed_user == 'true' && contains(needs.pr-info.outputs.args, '--boot.iso')
runs-on: [self-hosted, kstest]
timeout-minutes: 300
env:
Expand Down Expand Up @@ -152,7 +165,7 @@ jobs:
mkdir -p ./anaconda_rpms/
cp -av ./result/build/01-rpm-build/*.rpm ./anaconda_rpms/

- name: Build the boot.iso
- name: Build the ISO image
run: |
mkdir -p images
if [[ "${{ needs.pr-info.outputs.args }}" == *"--webui"* ]] ; then
Expand All @@ -178,7 +191,7 @@ jobs:
- name: Upload image
uses: actions/upload-artifact@v3
with:
name: image ${{ needs.pr-info.outputs.image_description }}
name: boot.iso image for ${{ needs.pr-info.outputs.image_description }}
path: |
images/*.iso

Expand All @@ -205,4 +218,79 @@ jobs:
target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

live-cd:
needs: pr-info
if: needs.pr-info.outputs.allowed_user == 'true' && contains(needs.pr-info.outputs.args, '--live')
runs-on: [self-hosted, kstest]
timeout-minutes: 300
env:
STATUS_NAME: live-cd
CONTAINER_TAG: 'lorax'
ISO_BUILD_CONTAINER_NAME: 'quay.io/rhinstaller/anaconda-live-iso-creator'
steps:
# we post statuses manually as this does not run from a pull_request event
# https://developer.github.com/v3/repos/statuses/#create-a-status
- name: Create in-progress status
uses: octokit/[email protected]
with:
route: 'POST /repos/${{ github.repository }}/statuses/${{ needs.pr-info.outputs.sha }}'
context: '${{ env.STATUS_NAME }} ${{ needs.pr-info.outputs.launch_args }}'
state: pending
target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Clone repository
uses: actions/checkout@v3
with:
ref: ${{ needs.pr-info.outputs.sha }}
fetch-depth: 0

- name: Build anaconda-rpm container (for RPM build)
run: |
# set static tag to avoid complications when looking what tag is used
make -f ./Makefile.am anaconda-rpm-build CI_TAG=$CONTAINER_TAG

- name: Build Anaconda RPM files
run: |
# output of the build will be stored in ./result/build/01-rpm-build/*.rpm
make -f ./Makefile.am container-rpms-scratch CI_TAG=$CONTAINER_TAG

- name: Build the ISO image
run: |
mkdir -p images
make -f Makefile.am container-live-iso-build
mv result/iso/Fedora-Workstation.iso "images/${{ needs.pr-info.outputs.image_description }}-Fedora-Workstation.iso"

- name: Make artefacts created by sudo cleanable
if: always()
run:
sudo chown -R github:github .

- name: Collect logs
if: always()
uses: actions/upload-artifact@v3
with:
name: 'logs'
path: |
images/*.log

- name: Upload image artifacts
uses: actions/upload-artifact@v3
with:
name: live image for ${{ needs.pr-info.outputs.image_description }}
path: |
images/*.iso

- name: Set result status
if: always()
uses: octokit/[email protected]
with:
route: 'POST /repos/${{ github.repository }}/statuses/${{ needs.pr-info.outputs.sha }}'
context: '${{ env.STATUS_NAME }} ${{ needs.pr-info.outputs.launch_args }}'
state: ${{ job.status }}
target_url: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
{% endif %}

0 comments on commit e2598c9

Please sign in to comment.