-
Notifications
You must be signed in to change notification settings - Fork 6
144 lines (121 loc) · 4.76 KB
/
build-ironic-images.yaml
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
---
name: build-ironic-images
on:
workflow_dispatch:
pull_request:
paths:
- 'ironic-images/**'
push:
branches:
- main
paths:
- 'ironic-images/**'
merge_group:
types: [checks_requested]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
discover:
runs-on: ubuntu-latest
outputs:
yaml-files: ${{ steps.set-matrix.outputs.yaml-files }}
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Find YAML files
id: set-matrix
run: |
yaml_files="[$(find . -maxdepth 1 -type f \( -name '*.yaml' -o -name '*.yml' \) -printf '"%f", ' | sed 's/, $//')]"
echo "yaml-files=${yaml_files}" >> $GITHUB_OUTPUT
working-directory: ironic-images
build-esp-image:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ironic-images
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Install Dependencies
run: sudo apt update && sudo apt install -y grub-efi-amd64-signed shim-signed mtools ipxe
- name: Create esp image
run: |
cp /usr/lib/shim/shimx64.efi.signed /tmp/bootx64.efi
cp /usr/lib/grub/x86_64-efi-signed/grubnetx64.efi.signed /tmp/grubx64.efi
dd if=/dev/zero of=/tmp/esp.img bs=4096 count=1024
mkfs.msdos -F 12 -n ESP_IMAGE /tmp/esp.img
mmd -i /tmp/esp.img EFI EFI/BOOT
mcopy -i /tmp/esp.img -v /tmp/bootx64.efi ::EFI/BOOT/BOOTX64.efi
mcopy -i /tmp/esp.img -v /tmp/grubx64.efi ::EFI/BOOT/GRUBX64.efi
mdir -i /tmp/esp.img ::EFI/BOOT
mkdir artifacts
cp /tmp/esp.img artifacts
- name: Copy ipxe images
run: cp /usr/lib/ipxe/{undionly.kpxe,ipxe.efi,snponly.efi} artifacts
- name: Show artifacts
run: ls -la artifacts
- name: Save artifacts for next job
uses: actions/upload-artifact@v4
with:
name: image-artifacts
path: ironic-images/artifacts/
build-tenant-images:
runs-on: ubuntu-latest
needs: [discover, build-esp-image]
defaults:
run:
working-directory: ironic-images
strategy:
matrix:
yaml-file: ${{ fromJson(needs.discover.outputs.yaml-files) }}
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Set up variables
run: |
echo "Processing YAML file: ${{ matrix.yaml-file }}"
imagename=$(grep -m 1 '^- imagename:' "${{ matrix.yaml-file }}" | awk '{print $3}')
echo "distro=${imagename%-*}" >> $GITHUB_ENV
echo "release=${imagename##*-}" >> $GITHUB_ENV
- name: Setup python environment
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5
id: setup-python
with:
python-version: '3.11'
cache: 'pip'
- name: Install Dependencies
run: sudo apt update && sudo apt install -y debootstrap qemu-utils squashfs-tools kpartx
- name: Install python packages
run: pip install -r requirements.txt
- name: Build Images
run: |
diskimage-builder ${{ matrix.yaml-file }}
mkdir -p upload
find . -maxdepth 1 -type f \( -name '*.qcow2' -o -name '*.kernel' -o -name '*.initramfs' \) -exec cp {} upload/ \;
env:
DIB_RELEASE: ${{ env.release }}
ELEMENTS_PATH: "${{ env.distro == 'ipa-debian' && format('{0}/share/ironic-python-agent-builder/dib:{1}/ironic-images/custom_elements', env.pythonLocation, github.workspace) || ''}}"
- name: Set timestamp environment variable
run: echo "TIMESTAMP=$(git show --no-patch --no-notes --pretty='%cd' --date=format:'%Y%m%d%H%M%S' ${{ github.sha }})" >> $GITHUB_ENV
- name: Download artifacts from previous job
uses: actions/download-artifact@v4
with:
name: image-artifacts
path: ironic-images/artifacts
- name: Copy image artifacts from previous job in to uploads directory
run: ls -la artifacts && cp -R artifacts/* upload/
- name: Publish Release
id: create_release
uses: softprops/action-gh-release@e7a8f85e1c67a31e6ed99a94b41bd0b71bbee6b8 # v2
with:
name: understack-images
tag_name: understack-images-${{ env.TIMESTAMP }}
make_latest: true
fail_on_unmatched_files: true
files: ironic-images/upload/*
# if: ${{ github.ref == 'refs/heads/main' }}
- name: Clean up artifacts
uses: geekyeggo/delete-artifact@v5
with:
name: image-artifacts