-
Notifications
You must be signed in to change notification settings - Fork 18
228 lines (212 loc) · 6.6 KB
/
rpm-builder.yaml
File metadata and controls
228 lines (212 loc) · 6.6 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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
---
name: rpm-builder
'on':
schedule:
# Rebuild images day-of-month 15 in January and July
- cron: '41 6 15 1,7 *'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
IMAGE_NAME: pkg-kamailio-docker
IMAGE_REPO: ghcr.io
jobs:
build:
name: Build image
strategy:
fail-fast: false
matrix:
os:
- alma-10
- centos-10
- rhel-10
- rocky-10
- alma-9
- centos-9
- rhel-9
- rocky-9
- alma-8
- centos-8
- rhel-8
- rocky-8
arch:
- x86_64
- aarch64
- ppc64le
- s390x
include:
# setting image platform
- platform: linux/amd64
arch: x86_64
- platform: linux/arm64/v8
arch: aarch64
- platform: linux/s390x
arch: s390x
- platform: linux/ppc64le
arch: ppc64le
# setting runner
- runner: ubuntu-latest
- runner: ubuntu-24.04-arm
arch: aarch64
# setting base iamge
- base_image: almalinux:10
os: alma-10
- base_image: almalinux:9
os: alma-9
- base_image: almalinux:8
os: alma-8
- base_image: quay.io/centos/centos:stream10
os: centos-10
- base_image: quay.io/centos/centos:stream9
os: centos-9
- base_image: quay.io/centos/centos:stream8
os: centos-8
- base_image: registry.redhat.io/ubi10/ubi:latest
os: rhel-10
- base_image: registry.redhat.io/ubi9/ubi:latest
os: rhel-9
- base_image: registry.redhat.io/ubi8/ubi:latest
os: rhel-8
- base_image: rockylinux/rockylinux:10
os: rocky-10
- base_image: rockylinux/rockylinux:9
os: rocky-9
- base_image: rockylinux/rockylinux:8
os: rocky-8
exclude:
# We does build for ppc64le because RedHat does not have CodeReady repo for ppc64le.
# more info at https://access.redhat.com/solutions/5500841
- os: rhel-10
arch: ppc64le
- os: rhel-9
arch: ppc64le
- os: rhel-8
arch: ppc64le
# also Codeready repo does not exist for rhel-9 and 10, s390x arch
- os: rhel-10
arch: s390x
- os: rhel-9
arch: s390x
# s390x arch does not exist for rhel 8, centos 8, rocky 8. For alma-8 cannot be compiled libphonenumber
- os: alma-8
arch: s390x
- os: centos-8
arch: s390x
- os: rhel-8
arch: s390x
- os: rocky-8
arch: s390x
# ppc64le arch does not exist for rocky 8
- os: rocky-8
arch: ppc64le
runs-on: ${{ matrix.runner }}
permissions:
contents: write
steps:
- name: Login to RedHat Container Registry
uses: docker/login-action@v4
if: contains(matrix.os, 'rhel')
with:
registry: registry.redhat.io
username: ${{ secrets.REDHAT_REGISTRY_LOGIN }}
password: ${{ secrets.REDHAT_REGISTRY_TOKEN }}
- name: checkout sources
uses: actions/checkout@v6
- name: print commit info
id: init
run: |
git log -n 1
- name: Image metadata
id: metadata
uses: docker/metadata-action@v6
with:
# list of Docker images to use as base name for tags
images: |
${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
tags: |
${{ matrix.os }}-${{ matrix.arch }}
flavor: |
latest=false
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
if: "! contains(fromJson('[\"x86_64\", \"aarch64\"]'), matrix.arch)"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Build builder image
uses: docker/build-push-action@v7
id: build
env:
DOCKER_BUILD_SUMMARY: false
with:
context: "{{defaultContext}}:rpm"
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
platforms: ${{ matrix.platform }}
secrets: |
"RHEL_USERNAME=${{ secrets.RHEL_USERNAME }}"
"RHEL_PASSWORD=${{ secrets.RHEL_PASSWORD }}"
build-args: |
base_image=${{ matrix.base_image }}
outputs: type=docker,dest=${{ runner.temp }}/${{ env.IMAGE_NAME }}-${{ matrix.os }}-${{ matrix.arch }}.tar
- name: Upload builder image as artifact
uses: actions/upload-artifact@v7
with:
name: ${{ env.IMAGE_NAME }}-${{ matrix.os }}-${{ matrix.arch }}
path: ${{ runner.temp }}/${{ env.IMAGE_NAME }}-${{ matrix.os }}-${{ matrix.arch }}.tar
push:
name: Push image to the repo
strategy:
matrix:
os:
- alma-10
- centos-10
- rhel-10
- rocky-10
- alma-9
- centos-9
- rhel-9
- rocky-9
- alma-8
- centos-8
- rhel-8
- rocky-8
runs-on: ubuntu-latest
permissions:
packages: write
needs:
- build
services:
registry:
image: registry:2
ports:
- 5000:5000
steps:
- name: Download artifact images
uses: actions/download-artifact@v8
with:
pattern: ${{ env.IMAGE_NAME }}-${{ matrix.os }}-*
path: ${{ runner.temp }}/tar-images
merge-multiple: true
- name: Login to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ${{ env.IMAGE_REPO }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pushing image to the local repo
run: |
set -o errexit -o nounset -o pipefail
jobj="[]"
for image_file in ${{ runner.temp }}/tar-images/*.tar; do
image_name=$(docker load --input ${image_file} | sed -e 's/Loaded image: //')
repo_image_name=$(echo localhost:5000/${image_name})
jobj=$(echo "${jobj}" | jq -c ". + [\"${repo_image_name}\"]")
docker image tag ${image_name} ${repo_image_name}
docker push ${repo_image_name}
done
eval_command=$(echo "${jobj}" | jq -r '["docker buildx imagetools create --tag localhost:5000/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ matrix.os }}"] + . | join(" ")')
eval "${eval_command}"
- name: Push image to GHCR
run: |
docker buildx imagetools create \
--tag ${{ env.IMAGE_REPO }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ matrix.os }} \
localhost:5000/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ matrix.os }}