Skip to content

Commit d700bb5

Browse files
sergey-safarovlinuxmaniac
authored andcommitted
prepare rpm builder using github actions [skip ci]
1 parent af7fa9c commit d700bb5

File tree

2 files changed

+234
-0
lines changed

2 files changed

+234
-0
lines changed

.github/workflows/rpm-builder.yaml

Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
---
2+
name: rpm-builder
3+
'on':
4+
schedule:
5+
# Rebuild images day-of-month 15 in January and July
6+
- cron: '41 6 15 1,7 *'
7+
# Allows you to run this workflow manually from the Actions tab
8+
workflow_dispatch:
9+
10+
env:
11+
IMAGE_NAME: pkg-kamailio-docker
12+
IMAGE_REPO: ghcr.io
13+
14+
jobs:
15+
build:
16+
name: Build image
17+
strategy:
18+
fail-fast: false
19+
matrix:
20+
os:
21+
- alma-10
22+
- centos-10
23+
- rhel-10
24+
- rocky-10
25+
- alma-9
26+
- centos-9
27+
- rhel-9
28+
- rocky-9
29+
- alma-8
30+
- centos-8
31+
- rhel-8
32+
- rocky-8
33+
arch:
34+
- x86_64
35+
- aarch64
36+
- ppc64le
37+
- s390x
38+
include:
39+
# setting image platform
40+
- platform: linux/amd64
41+
arch: x86_64
42+
- platform: linux/arm64/v8
43+
arch: aarch64
44+
- platform: linux/s390x
45+
arch: s390x
46+
- platform: linux/ppc64le
47+
arch: ppc64le
48+
49+
# setting runner
50+
- runner: ubuntu-latest
51+
- runner: ubuntu-24.04-arm
52+
arch: aarch64
53+
54+
# setting base iamge
55+
- base_image: almalinux:10
56+
os: alma-10
57+
- base_image: almalinux:9
58+
os: alma-9
59+
- base_image: almalinux:8
60+
os: alma-8
61+
- base_image: quay.io/centos/centos:stream10
62+
os: centos-10
63+
- base_image: quay.io/centos/centos:stream9
64+
os: centos-9
65+
- base_image: quay.io/centos/centos:stream8
66+
os: centos-8
67+
- base_image: registry.redhat.io/ubi10/ubi:latest
68+
os: rhel-10
69+
- base_image: registry.redhat.io/ubi9/ubi:latest
70+
os: rhel-9
71+
- base_image: registry.redhat.io/ubi8/ubi:latest
72+
os: rhel-8
73+
- base_image: rockylinux/rockylinux:10
74+
os: rocky-10
75+
- base_image: rockylinux/rockylinux:9
76+
os: rocky-9
77+
- base_image: rockylinux/rockylinux:8
78+
os: rocky-8
79+
exclude:
80+
# We does build for ppc64le because RedHat does not have CodeReady repo for ppc64le.
81+
# more info at https://access.redhat.com/solutions/5500841
82+
- os: rhel-10
83+
arch: ppc64le
84+
- os: rhel-9
85+
arch: ppc64le
86+
- os: rhel-8
87+
arch: ppc64le
88+
# also Codeready repo does not exist for rhel-9 and 10, s390x arch
89+
- os: rhel-10
90+
arch: s390x
91+
- os: rhel-9
92+
arch: s390x
93+
# s390x arch does not exist for rhel 8, centos 8, rocky 8. For alma-8 cannot be compiled libphonenumber
94+
- os: alma-8
95+
arch: s390x
96+
- os: centos-8
97+
arch: s390x
98+
- os: rhel-8
99+
arch: s390x
100+
- os: rocky-8
101+
arch: s390x
102+
# ppc64le arch does not exist for rocky 8
103+
- os: rocky-8
104+
arch: ppc64le
105+
106+
runs-on: ${{ matrix.runner }}
107+
permissions:
108+
contents: write
109+
steps:
110+
- name: Login to RedHat Container Registry
111+
uses: docker/login-action@v3
112+
if: contains(matrix.os, 'rhel')
113+
with:
114+
registry: registry.redhat.io
115+
username: ${{ secrets.REDHAT_REGISTRY_LOGIN }}
116+
password: ${{ secrets.REDHAT_REGISTRY_TOKEN }}
117+
118+
- name: checkout sources
119+
uses: actions/checkout@v4
120+
121+
- name: print commit info
122+
id: init
123+
run: |
124+
git log -n 1
125+
126+
- name: Image metadata
127+
id: metadata
128+
uses: docker/metadata-action@v5
129+
with:
130+
# list of Docker images to use as base name for tags
131+
images: |
132+
${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
133+
tags: |
134+
${{ matrix.os }}-${{ matrix.arch }}
135+
flavor: |
136+
latest=false
137+
138+
- name: Set up QEMU
139+
uses: docker/setup-qemu-action@v3
140+
if: "! contains(fromJson('[\"x86_64\", \"aarch64\"]'), matrix.arch)"
141+
142+
- name: Set up Docker Buildx
143+
uses: docker/setup-buildx-action@v3
144+
145+
- name: Build builder image
146+
uses: docker/build-push-action@v6
147+
id: build
148+
env:
149+
DOCKER_BUILD_SUMMARY: false
150+
with:
151+
context: "{{defaultContext}}:rpm"
152+
tags: ${{ steps.metadata.outputs.tags }}
153+
labels: ${{ steps.metadata.outputs.labels }}
154+
platforms: ${{ matrix.platform }}
155+
secrets: |
156+
"RHEL_USERNAME=${{ secrets.RHEL_USERNAME }}"
157+
"RHEL_PASSWORD=${{ secrets.RHEL_PASSWORD }}"
158+
build-args: |
159+
base_image=${{ matrix.base_image }}
160+
outputs: type=docker,dest=${{ runner.temp }}/${{ env.IMAGE_NAME }}-${{ matrix.os }}-${{ matrix.arch }}.tar
161+
162+
- name: Upload builder image as artifact
163+
uses: actions/upload-artifact@v4
164+
with:
165+
name: ${{ env.IMAGE_NAME }}-${{ matrix.os }}-${{ matrix.arch }}
166+
path: ${{ runner.temp }}/${{ env.IMAGE_NAME }}-${{ matrix.os }}-${{ matrix.arch }}.tar
167+
168+
push:
169+
name: Push image to the repo
170+
strategy:
171+
matrix:
172+
os:
173+
- alma-10
174+
- centos-10
175+
- rhel-10
176+
- rocky-10
177+
- alma-9
178+
- centos-9
179+
- rhel-9
180+
- rocky-9
181+
- alma-8
182+
- centos-8
183+
- rhel-8
184+
- rocky-8
185+
runs-on: ubuntu-latest
186+
permissions:
187+
packages: write
188+
needs:
189+
- build
190+
services:
191+
registry:
192+
image: registry:2
193+
ports:
194+
- 5000:5000
195+
steps:
196+
- name: Download artifact images
197+
uses: actions/download-artifact@v4
198+
with:
199+
pattern: ${{ env.IMAGE_NAME }}-${{ matrix.os }}-*
200+
path: ${{ runner.temp }}/tar-images
201+
merge-multiple: true
202+
203+
- name: Login to GitHub Container Registry
204+
uses: docker/login-action@v3
205+
with:
206+
registry: ${{ env.IMAGE_REPO }}
207+
username: ${{ github.repository_owner }}
208+
password: ${{ secrets.GITHUB_TOKEN }}
209+
210+
- name: Pushing image to the local repo
211+
run: |
212+
set -o errexit -o nounset -o pipefail
213+
jobj="[]"
214+
for image_file in ${{ runner.temp }}/tar-images/*.tar; do
215+
image_name=$(docker load --input ${image_file} | sed -e 's/Loaded image: //')
216+
repo_image_name=$(echo localhost:5000/${image_name})
217+
jobj=$(echo "${jobj}" | jq -c ". + [\"${repo_image_name}\"]")
218+
docker image tag ${image_name} ${repo_image_name}
219+
docker push ${repo_image_name}
220+
done
221+
eval_command=$(echo "${jobj}" | jq -r '["docker buildx imagetools create --tag localhost:5000/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ matrix.os }}"] + . | join(" ")')
222+
eval "${eval_command}"
223+
224+
- name: Push image to GHCR
225+
run: |
226+
docker buildx imagetools create \
227+
--tag ${{ env.IMAGE_REPO }}/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ matrix.os }} \
228+
localhost:5000/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}:${{ matrix.os }}

rpm/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,9 @@ Suported dist
5151
| rocky | 9 |x86_64, aarch64, s390x, ppc64le|
5252
| fedora | 42 |x86_64, aarch64, s390x, ppc64le|
5353
| fedora | 41 |x86_64, aarch64, s390x, ppc64le|
54+
55+
For GitHub actions required specify in repository "Secrets and variables -> Actions":
56+
1. REDHAT_REGISTRY_LOGIN - login to pull `ubi` docker images
57+
2. REDHAT_REGISTRY_TOKEN - security token to pull `ubi` docker images
58+
3. RHEL_USERNAME - login to get access for RHEL subscription
59+
4. RHEL_PASSWORD - password to get access for RHEL subscription

0 commit comments

Comments
 (0)