Skip to content

Commit 80a13c5

Browse files
committed
refactor build-iso to build-bootable-artifacts
leverages https://github.com/osbuild/bootc-image-builder-action instead of unmaintained original bootc-image-builder-action
1 parent fc714ca commit 80a13c5

9 files changed

Lines changed: 192 additions & 163 deletions

File tree

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
---
2+
name: Build bootable artifacts
3+
4+
inputs:
5+
platform:
6+
description: The platform to build the image for (e.g., "x86_64", "arm64")
7+
required: true
8+
image:
9+
description: Full podman image reference, including hash (e.g., "registry.example.com/image@sha256")
10+
required: true
11+
image-name:
12+
description: Name of the image, will be used to name the artifact files (e.g., "my-image")
13+
required: true
14+
image-types:
15+
description: The types of bootable artifacts to build (e.g., "iso,raw")
16+
required: false
17+
default: "iso"
18+
update_is_signed:
19+
description: Whether the image is signed or not
20+
required: false
21+
update_origin_ref:
22+
description: Image reference to update from (e.g., "{image}:latest")
23+
required: true
24+
config-file:
25+
description: Path to the bootable artifacts configuration file
26+
required: true
27+
use-librepo:
28+
description: "Use librepo to download the image"
29+
required: false
30+
additional-args:
31+
description: "Additional arguments to pass to the bootc-image-builder"
32+
required: false
33+
REGISTRY:
34+
description: The container registry URL (e.g., "registry.example.com")
35+
required: true
36+
REGISTRY_USER:
37+
description: The username for the container registry login
38+
required: true
39+
REGISTRY_TOKEN:
40+
description: The token for authenticating with the container registry
41+
required: true
42+
43+
outputs:
44+
output_directory:
45+
description: The directory where the built artifacts and checksums are stored
46+
value: ${{ steps.rename.outputs.output_directory }}
47+
artifact_basename:
48+
description: The base name of the artifacts
49+
value: ${{ steps.rename.outputs.artifact_basename }}
50+
51+
runs:
52+
using: "composite"
53+
steps:
54+
- name: Login to Container Registry
55+
uses: redhat-actions/podman-login@4934294ad0449894bcd1e9f191899d7292469603 # v1.7
56+
with:
57+
registry: ${{ inputs.REGISTRY }}
58+
username: ${{ inputs.REGISTRY_USER }}
59+
password: ${{ inputs.REGISTRY_TOKEN }}
60+
61+
- name: Set up environment
62+
id: set-env
63+
shell: bash
64+
run: |
65+
ARCH=${{ inputs.platform }}
66+
echo "CLEAN_ARCH=${ARCH//\//_}" >> "$GITHUB_ENV"
67+
68+
- name: Prepare bootable artifacts configuration
69+
shell: bash
70+
run: |
71+
[ "${{ inputs.update_is_signed }}" = "true" ] && SIG="--enforce-container-sigpolicy"
72+
73+
sed -i 's#<UPDATE_IMAGE_REF>#${{ inputs.update_origin_ref }}#g' ${{ inputs.config-file }}
74+
sed -i "s#<IMAGE_SIGNED>#${SIG}#g" ${{ inputs.config-file }}
75+
cat ${{ inputs.config-file }}
76+
77+
[ "${{ inputs.use-librepo }}" = "true" ] && USE_LIBREPO="True" || USE_LIBREPO="False"
78+
ADDITIONAL_ARGS="--target-arch=${{ env.CLEAN_ARCH }} --use-librepo=${USE_LIBREPO} ${{ inputs.additional-args }}"
79+
80+
echo "ADDITIONAL_ARGS=${ADDITIONAL_ARGS}" >> "$GITHUB_ENV"
81+
82+
if [[ "${ADDITIONAL_ARGS}" == *"--installer-payload-ref"* ]]; then
83+
INSTALLER_PAYLOAD_REF=$(echo "${ADDITIONAL_ARGS}" | grep -oP '(?<=--installer-payload-ref[= ])\S+')
84+
sudo podman pull "${INSTALLER_PAYLOAD_REF}"
85+
fi
86+
87+
- name: Build bootable artifacts
88+
id: build
89+
uses: osbuild/bootc-image-builder-action@4503a3445240ffc85cccf8f57d7cab5634e351e2
90+
with:
91+
config-file: ${{ inputs.config-file }}
92+
image: ${{ inputs.image }}
93+
additional-args: ${{ env.ADDITIONAL_ARGS }}
94+
types: ${{ inputs.image-types }}
95+
96+
- name: Rename bootable artifacts
97+
id: rename
98+
env:
99+
OUTPUT_PATH: output-${{ env.CLEAN_ARCH }}
100+
shell: bash
101+
run: |
102+
set -x
103+
mkdir -p ${{ env.OUTPUT_PATH }}
104+
OUTPUT_DIRECTORY="$(realpath ${{ env.OUTPUT_PATH }})"
105+
ARTIFACT_BASENAME="${{ inputs.image-name }}-${{ env.CLEAN_ARCH }}"
106+
107+
echo '${{ steps.build.outputs.output-paths }}' | jq -c '.[]' | while read -r artifact; do
108+
ARTIFACT_PATH=$(echo "$artifact" | jq -r '.path')
109+
ARTIFACT_CHECKSUM=$(echo "$artifact" | jq -r '.checksum')
110+
ARTIFACT_EXTENSION=$(echo "$ARTIFACT_PATH" | awk -F. '{print $NF}')
111+
112+
ARTIFACT_NAME="${ARTIFACT_BASENAME}.${ARTIFACT_EXTENSION}"
113+
CHECKSUM_NAME="${ARTIFACT_NAME}-CHECKSUM"
114+
115+
cp "$ARTIFACT_PATH" "${OUTPUT_DIRECTORY}/${ARTIFACT_NAME}"
116+
echo "$ARTIFACT_CHECKSUM" > "${OUTPUT_DIRECTORY}/${CHECKSUM_NAME}"
117+
done
118+
119+
echo "output_directory=${OUTPUT_DIRECTORY}" >> "${GITHUB_OUTPUT}"
120+
echo "artifact_basename=${ARTIFACT_BASENAME}" >> "${GITHUB_OUTPUT}"

.github/actions/build-iso/action.yml

Lines changed: 0 additions & 108 deletions
This file was deleted.

.github/actions/build/action.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,19 @@ inputs:
77
required: true
88
variant:
99
description: The variant of the image to build
10-
required: true
10+
required: false
11+
default: ""
1112
containerfile:
1213
description: The path to the Containerfile used for building the image
1314
required: true
15+
stage:
16+
description: The stage to build in the Containerfile
17+
required: false
18+
default: ""
19+
extra-args:
20+
description: Additional arguments to pass to the podman build command
21+
required: false
22+
default: ""
1423
image-name:
1524
description: The name of the image to build
1625
required: true
@@ -99,6 +108,8 @@ runs:
99108
shell: bash
100109
env:
101110
IMAGE_TAG: ${{ inputs.image-tag }}-${{ env.CLEAN_ARCH }}
111+
STAGE_ARGS: --target=${{ inputs.stage }}
112+
EXTRA_ARGS: ${{ inputs.extra-args }}
102113
run: |
103114
echo "::group::Build Image"
104115
sudo podman build \
@@ -113,6 +124,8 @@ runs:
113124
--build-arg VARIANT=${{ inputs.variant }} \
114125
-t ${{ inputs.image-name }}:${IMAGE_TAG} \
115126
-f ${{ inputs.containerfile }} \
127+
${{ env.STAGE_ARGS }} \
128+
${{ env.EXTRA_ARGS }} \
116129
.
117130
118131
echo "image-id=$(cat /tmp/image-id)" >> $GITHUB_OUTPUT

.github/actions/upload-gh/action.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
name: Upload to GitHub Actions Artifacts
33

44
inputs:
5-
artifact_name:
6-
description: "The name of the artifact to upload"
5+
artifact_basename:
6+
description: "The basename of the artifacts to upload"
77
required: true
88
directory:
99
description: "The directory containing the files to upload"
@@ -12,11 +12,11 @@ inputs:
1212
runs:
1313
using: "composite"
1414
steps:
15-
- name: Upload ISOs and Checksum to Job Artifacts
15+
- name: Upload Bootable Artifacts and Checksums to Job Artifacts
1616
id: upload-gh
1717
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v4
1818
with:
19-
name: ${{ inputs.artifact_name }}
19+
name: ${{ inputs.artifact_basename }}
2020
path: ${{ inputs.directory }}
2121
if-no-files-found: error
2222
compression-level: 0
@@ -26,5 +26,5 @@ runs:
2626
- name: Summary
2727
shell: bash
2828
run: |
29-
echo "Artifact URL: ${{ steps.upload-gh.outputs.artifact-url }}" >> $GITHUB_STEP_SUMMARY
29+
echo "Artifact: ${{ steps.upload-gh.outputs.artifact-url }}" >> $GITHUB_STEP_SUMMARY
3030
echo "Digest: ${{ steps.upload-gh.outputs.artifact-digest }}" >> $GITHUB_STEP_SUMMARY

.github/actions/upload-r2/action.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ inputs:
88
bucket:
99
description: "The Cloudflare R2 bucket to upload the files to"
1010
required: true
11+
path:
12+
description: "The path to the files to upload, relative to the bucket root"
13+
required: true
14+
default: ""
1115
R2_ACCOUNT_ID:
1216
description: "The Cloudflare R2 account ID"
1317
required: true
@@ -30,4 +34,4 @@ runs:
3034
r2-secret-access-key: ${{ inputs.R2_SECRET_ACCESS_KEY }}
3135
r2-bucket: ${{ inputs.bucket }}
3236
source-dir: ${{ inputs.directory }}
33-
destination-dir: ./
37+
destination-dir: ${{ inputs.path }}

.github/actions/upload-s3/action.yml

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,12 @@ inputs:
66
description: "The directory containing the files to upload"
77
required: true
88
bucket:
9-
description: "The Cloudflare R2 bucket to upload the files to"
9+
description: "The Amazon S3 bucket to upload the files to"
1010
required: true
1111
path:
12-
description: "The path to the files to upload, relative to the directory"
13-
required: true
14-
iso-name:
15-
description: "The name of the ISO file to upload"
16-
required: true
17-
checksum-name:
18-
description: "The name of the checksum file to upload"
12+
description: "The path to the files to upload, relative to the bucket root"
1913
required: true
14+
default: ""
2015
aws-default-region:
2116
description: "The AWS region to use for S3 uploads"
2217
required: true
@@ -46,18 +41,4 @@ runs:
4641
# Upload the files to S3 bucket
4742
aws s3 cp ${{ inputs.directory }} \
4843
s3://${BUCKET}/${{ inputs.path }}/ \
49-
--recursive
50-
51-
# Make them uploaded file publicly available
52-
aws s3api put-object-tagging \
53-
--bucket ${BUCKET} \
54-
--key ${{ inputs.path }}/${{ inputs.iso-name }} \
55-
--tagging 'TagSet={Key=public,Value=yes}'
56-
57-
aws s3api put-object-tagging \
58-
--bucket ${BUCKET} \
59-
--key ${{ inputs.path }}/${{ inputs.checksum-name }} \
60-
--tagging 'TagSet={Key=public,Value=yes}'
61-
62-
echo "ISO: https://${BUCKET}.s3-accelerate.dualstack.amazonaws.com/${{ inputs.path }}/${{ inputs.iso-name }}" >> $GITHUB_STEP_SUMMARY
63-
echo "Digest: https://${BUCKET}.s3-accelerate.dualstack.amazonaws.com/${{ inputs.path }}/${{ inputs.checksum-name }}" >> $GITHUB_STEP_SUMMARY
44+
--recursive --acl public-read

0 commit comments

Comments
 (0)