-
-
Notifications
You must be signed in to change notification settings - Fork 10
208 lines (179 loc) · 7.07 KB
/
Copy pathbuild.yml
File metadata and controls
208 lines (179 loc) · 7.07 KB
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
---
name: Build container image
on:
pull_request:
branches: ['*']
schedule:
- cron: '05 10 * * *' # 10:05am UTC everyday
push:
branches: ['*']
paths-ignore:
- '**/README.md'
- 'releases.json'
workflow_dispatch:
env:
IMAGE_DESC: "Zena"
IMAGE_NAME: "${{ github.event.repository.name }}"
IMAGE_REGISTRY: "ghcr.io/${{ github.repository_owner }}"
FEDORA_VERSION: "43"
DEFAULT_TAG: "latest"
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}-${{ inputs.brand_name}}-${{ inputs.stream_name }}
cancel-in-progress: true
jobs:
build_push:
name: Build and push image
strategy:
fail-fast: false
matrix:
flavor: ["", "nvidia"]
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
id-token: write
timeout-minutes: 30
steps:
- name: Change image name depending on build flavor
env:
BUILD_FLAVOR: ${{ matrix.flavor }}
run: |
if [ "${BUILD_FLAVOR}" != "" ] ; then
echo "IMAGE_NAME=${IMAGE_NAME}-${{ matrix.flavor }}" >> $GITHUB_ENV
fi
- name: Lower case image variables
run: |
echo "IMAGE_REGISTRY=${IMAGE_REGISTRY,,}" >> ${GITHUB_ENV}
echo "IMAGE_NAME=${IMAGE_NAME,,}" >> ${GITHUB_ENV}
- name: Set tag prefix
if: github.ref_name != 'main'
run: |
echo "TAG_PREFIX=${{ github.ref_name }}." >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v6
- name: Mount BTRFS for podman storage
id: container-storage-action
uses: ublue-os/container-storage-action@main
continue-on-error: true
with:
target-dir: /var/lib/containers
mount-opts: compress-force=zstd:2
- name: Get current date
id: date
run: |
echo "date=$(date -u +%Y\-%m\-%d\T%H\:%M\:%S\Z)" >> $GITHUB_OUTPUT
- name: Image Metadata
uses: docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 # v6.1.0
id: metadata
with:
tags: |
type=raw,value=${{ env.TAG_PREFIX }}{{date 'YYYYMMDD'}}
type=raw,value=${{ env.TAG_PREFIX }}${{ env.DEFAULT_TAG }}
type=raw,value=${{ env.TAG_PREFIX }}${{ env.FEDORA_VERSION }}
type=raw,value=${{ env.TAG_PREFIX }}${{ env.FEDORA_VERSION }}.{{date 'YYYYMMDD'}}
type=sha,enable=${{ github.event_name == 'pull_request' }}
type=ref,event=pr
labels: |
org.opencontainers.image.created=${{ steps.date.outputs.date }}
org.opencontainers.image.description=${{ env.IMAGE_DESC }}
org.opencontainers.image.documentation=https://raw.githubusercontent.com/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}/${{ github.sha }}/README.md
org.opencontainers.image.source=https://github.com/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}/blob/${{ github.sha }}/Containerfile
org.opencontainers.image.title=${{ env.IMAGE_NAME }}
org.opencontainers.image.url=https://github.com/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}/tree/${{ github.sha }}
org.opencontainers.image.vendor=${{ github.repository_owner }}
org.opencontainers.image.version=${{ env.FEDORA_VERSION }}.{{date 'YYYYMMDD'}}
containers.bootc=1
sep-tags: ' '
sep-annotations: ' '
- name: Check secure boot key
id: secret-check
run: |
if [ -z "${{ secrets.SECUREBOOT_KEY }}" ]; then
echo "present=false" >> $GITHUB_OUTPUT
else
echo "present=true" >> $GITHUB_OUTPUT
fi
- name: Decode Secure Boot keys
if: steps.secret-check.outputs.present == 'true'
run: |
echo "$SECUREBOOT_KEY" | base64 --decode > system-files/common/secureboot/MOK.key
chmod 600 system-files/common/secureboot/MOK.key
env:
SECUREBOOT_KEY: ${{ secrets.SECUREBOOT_KEY }}
- name: Prepare build args file
run: |
cat <<'EOF' >>build_args.txt
FEDORA_VERSION=${{ env.FEDORA_VERSION }}
IMAGE=${{ env.IMAGE_NAME }}
EOF
- name: Build Image
id: build_image
run: |
sudo -E buildah build \
--file Containerfile \
--build-arg-file build_args.txt \
--tag raw-img .
- name: Run Rechunker
id: rechunk
uses: ublue-os/legacy-rechunk@a925083d9af7cb04b3e2a6e8c01bfa495f38b710 # v1.0.0
with:
rechunk: 'ghcr.io/ublue-os/legacy-rechunk:v1.0.0-x86_64'
ref: 'raw-img'
prev-ref: '${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.DEFAULT_TAG }}'
skip_compression: false
version: '${{ steps.metadata.outputs.tags }}'
labels: '${{ steps.metadata.outputs.labels }}'
- name: Load in podman and tag
run: |
IMAGE=$(podman pull ${{ steps.rechunk.outputs.ref }})
sudo rm -rf ${{ steps.rechunk.outputs.output }}
for tag in ${{ steps.metadata.outputs.tags }}; do
podman tag $IMAGE "${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:$tag"
done
- name: Login to GitHub Container Registry
uses: docker/login-action@af1e73f918a031802d376d3c8bbc3fe56130a9b0
if: github.event_name != 'pull_request'
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push To GHCR
if: github.event_name != 'pull_request'
run: |
set -euo pipefail
retries=5
delay=10
# Loop through each tag
for tag in ${{ steps.metadata.outputs.tags }}; do
echo "Pushing tag: $tag"
for attempt in $(seq 1 $retries); do
echo " Attempt $attempt/$retries for $tag..."
if podman push "${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:$tag" --tls-verify=true; then
echo " Push of $tag succeeded"
break
fi
if [ "$attempt" -lt "$retries" ]; then
echo " Push of $tag failed — retrying in $delay seconds..."
sleep $delay
else
echo " Push of $tag failed after $retries attempts"
exit 1
fi
done
done
- name: Install Cosign
uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6
if: github.event_name != 'pull_request'
with:
cosign-release: 'v2.6.1'
- name: Sign container image
if: github.event_name != 'pull_request'
run: |
IMAGE_FULL="${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}"
for tag in ${{ steps.metadata.outputs.tags }}; do
cosign sign -y --key env://COSIGN_PRIVATE_KEY $IMAGE_FULL:$tag
done
env:
TAGS: ${{ steps.push.outputs.digest }}
COSIGN_EXPERIMENTAL: false
COSIGN_PRIVATE_KEY: ${{ secrets.SIGNING_SECRET }}