-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
109 lines (96 loc) · 3.66 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: Bootc Image Builder
description: Build bootc images into disk images or ISOs
inputs:
config-file:
description: 'Path to the config file'
required: true
type:
description: 'Type of image to build (e.g. iso)'
required: false
default: 'iso'
image:
description: 'Name of the image (e.g. ghcr.io/myorg/myimage:latest)'
required: true
bootc-image-builder-image:
description: 'Name of the bootc image builder image'
required: false
default: 'quay.io/centos-bootc/bootc-image-builder:latest'
outputs:
output-directory:
description: 'Directory containing the built image'
value: ${{ steps.set-outputs.outputs.output_directory }}
output-path:
description: 'Path to the built image'
value: ${{ steps.set-outputs.outputs.path }}
checksum-path:
description: 'Checksum of the built image'
value: ${{ steps.set-outputs.outputs.checksum_path }}
checksum:
description: 'Checksum of the built image'
value: ${{ steps.set-outputs.outputs.checksum }}
runs:
using: 'composite'
steps:
- name: Configure Podman
shell: bash
run: |
sudo mkdir -p /etc/containers
echo -e "[storage]\ndriver = \"overlay\"\nrunroot = \"/run/containers/storage\"\ngraphroot = \"/var/lib/containers/storage\"" \
| sudo tee /etc/containers/storage.conf
# workaround https://github.com/containers/podman/issues/21683
sudo apt install -y sqlite3
echo "update DBConfig set GraphDriver = 'overlay' where GraphDriver = '';" | sudo sh -c '(cd /var/lib/containers/storage && sqlite3 db.sql)'
- name: Pull Image
shell: bash
run:
sudo podman pull ${{ inputs.image }}
- name: Build ISO
if: ${{ inputs.type == 'iso' }}
id: build
shell: bash
env:
CONFIG_FILE: ${{ inputs.config-file }}
IMAGE: ${{ inputs.image }}
BOOTC_IMAGE_BUILDER_IMAGE: ${{ inputs.bootc-image-builder-image }}
run: |
DESIRED_UID=$(id -u)
DESIRED_GID=$(id -g)
CONFIG_FILE_EXTENSION="${CONFIG_FILE##*.}"
mkdir -p ./output
sudo podman run \
--rm \
--privileged \
--pull=newer \
--security-opt label=type:unconfined_t \
-v $CONFIG_FILE:/config.$CONFIG_FILE_EXTENSION:ro \
-v ./output:/output \
-v /var/lib/containers/storage:/var/lib/containers/storage \
$BOOTC_IMAGE_BUILDER_IMAGE \
--type iso \
--local \
--chown $DESIRED_UID:$DESIRED_GID \
$IMAGE
ISO_PATH=$(ls ./output/bootiso/*.iso)
# Create a checksum of the output file, stored in the same directory
CHECKSUM=$(sha256sum $ISO_PATH | awk '{print $1}')
CHECKSUM_PATH=${ISO_PATH}-CHECKSUM
echo $CHECKSUM > ${CHECKSUM_PATH}
# Get the parent directory of the ISO
OUTPUT_DIRECTORY=$(dirname $ISO_PATH)
echo "OUTPUT_DIRECTORY=$OUTPUT_DIRECTORY" >> $GITHUB_OUTPUT
echo "CHECKSUM=$CHECKSUM" >> $GITHUB_OUTPUT
echo "CHECKSUM_PATH=$CHECKSUM_PATH" >> $GITHUB_OUTPUT
echo "ISO_PATH=$ISO_PATH" >> $GITHUB_OUTPUT
- name: Set Outputs
id: set-outputs
shell: bash
env:
OUTPUT_DIRECTORY: ${{ steps.build.outputs.OUTPUT_DIRECTORY }}
CHECKSUM: ${{ steps.build.outputs.CHECKSUM }}
CHECKSUM_PATH: ${{ steps.build.outputs.CHECKSUM_PATH }}
ISO_PATH: ${{ steps.build.outputs.ISO_PATH }}
run: |
echo "output_directory=$OUTPUT_DIRECTORY" >> $GITHUB_OUTPUT
echo "checksum=$CHECKSUM" >> $GITHUB_OUTPUT
echo "checksum_path=$CHECKSUM_PATH" >> $GITHUB_OUTPUT
echo "path=$ISO_PATH" >> $GITHUB_OUTPUT