Skip to content

Commit ab5d820

Browse files
committed
[WIP] .github: workflows: Use buildah
1 parent 4c5cb4c commit ab5d820

File tree

1 file changed

+109
-146
lines changed

1 file changed

+109
-146
lines changed

.github/workflows/ci.yml

Lines changed: 109 additions & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,20 @@ concurrency:
1919
group: ${{ github.ref }}
2020
cancel-in-progress: true
2121

22+
env:
23+
DOCKERHUB_BASE: docker.io/zephyrprojectrtos
24+
GHCR_BASE: ghcr.io/zephyrproject-rtos
25+
BASE_IMAGE_NAME: ci-base-testing
26+
CI_IMAGE_NAME: ci-testing
27+
DEVELOPER_IMAGE_NAME: zephyr-build-testing
28+
2229
jobs:
2330
build:
2431
name: Build (${{ matrix.variant.platform }})
2532
runs-on:
2633
group: ${{ matrix.variant.builder }}
34+
container:
35+
image: ghcr.io/zephyrproject-rtos/image-build:v1.0.0
2736

2837
strategy:
2938
fail-fast: true
@@ -36,215 +45,169 @@ jobs:
3645
arch: arm64
3746
builder: zephyr-runner-v2-linux-arm64-4xlarge
3847

39-
services:
40-
registry:
41-
image: registry:2
42-
ports:
43-
- 5000:5000
44-
4548
steps:
4649
- name: Checkout
4750
uses: actions/checkout@v3
4851

49-
- name: Generate local metadata for base image
50-
id: meta_ci_base
51-
uses: docker/metadata-action@v4
52-
with:
53-
images: |
54-
localhost:5000/zephyrproject-rtos/ci-base-testing
55-
56-
- name: Generate local metadata for CI image
57-
id: meta_ci
58-
uses: docker/metadata-action@v4
52+
- name: Login to DockerHub
53+
if: ${{ github.event_name != 'pull_request' }}
54+
uses: redhat-actions/podman-login@v1
5955
with:
60-
images: |
61-
localhost:5000/zephyrproject-rtos/ci-testing
56+
registry: docker.io
57+
username: ${{ vars.DOCKERHUB_USERNAME }}
58+
password: ${{ secrets.DOCKERHUB_TOKEN }}
6259

63-
- name: Generate local metadata for Developer image
64-
id: meta_developer
65-
uses: docker/metadata-action@v4
60+
- name: Login to GitHub Container Registry
61+
if: ${{ github.event_name != 'pull_request' }}
62+
uses: redhat-actions/podman-login@v1
6663
with:
67-
images: |
68-
localhost:5000/zephyrproject-rtos/zephyr-build-testing
64+
registry: ghcr.io
65+
username: ${{ github.repository_owner }}
66+
password: ${{ secrets.GITHUB_TOKEN }}
6967

70-
- name: Generate push metadata for base image
68+
- name: Generate metadata for base image
7169
if: ${{ github.event_name != 'pull_request' }}
72-
id: meta_ci_base_push
70+
id: meta_ci_base
7371
uses: docker/metadata-action@v4
7472
with:
7573
images: |
76-
docker.io/zephyrprojectrtos/ci-base-testing
77-
ghcr.io/zephyrproject-rtos/ci-base-testing
74+
${{ env.DOCKERHUB_BASE }}/${{ env.BASE_IMAGE_NAME }}
75+
${{ env.GHCR_BASE }}/${{ env.BASE_IMAGE_NAME }}
7876
flavor: |
7977
latest=false
8078
suffix=-${{ matrix.variant.arch }}
8179
tags: |
8280
type=ref,event=branch
8381
type=ref,event=tag
8482
85-
- name: Generate push metadata for CI image
83+
- name: Generate metadata for CI image
8684
if: ${{ github.event_name != 'pull_request' }}
87-
id: meta_ci_push
85+
id: meta_ci
8886
uses: docker/metadata-action@v4
8987
with:
9088
images: |
91-
docker.io/zephyrprojectrtos/ci-testing
92-
ghcr.io/zephyrproject-rtos/ci-testing
89+
${{ env.DOCKERHUB_BASE }}/${{ env.CI_IMAGE_NAME }}
90+
${{ env.GHCR_BASE }}/${{ env.CI_IMAGE_NAME }}
9391
flavor: |
9492
latest=false
9593
suffix=-${{ matrix.variant.arch }}
9694
tags: |
9795
type=ref,event=branch
9896
type=ref,event=tag
9997
100-
- name: Generate push metadata for Developer image
98+
- name: Generate metadata for Developer image
10199
if: ${{ github.event_name != 'pull_request' }}
102-
id: meta_developer_push
100+
id: meta_developer
103101
uses: docker/metadata-action@v4
104102
with:
105103
images: |
106-
docker.io/zephyrprojectrtos/zephyr-build-testing
107-
ghcr.io/zephyrproject-rtos/zephyr-build-testing
104+
${{ env.DOCKERHUB_BASE }}/${{ env.DEVELOPER_IMAGE_NAME }}
105+
${{ env.GHCR_BASE }}/${{ env.DEVELOPER_IMAGE_NAME }}
108106
flavor: |
109107
latest=false
110108
suffix=-${{ matrix.variant.arch }}
111109
tags: |
112110
type=ref,event=branch
113111
type=ref,event=tag
114112
115-
- name: Set up Docker Buildx
116-
uses: docker/setup-buildx-action@v2
117-
with:
118-
driver-opts: network=host
119-
120-
- name: Build base docker image
121-
uses: docker/build-push-action@v3
113+
- name: Build base image
114+
uses: redhat-actions/buildah-build@v2
122115
with:
123116
context: .
124-
file: Dockerfile.base
125-
platforms: ${{ matrix.variant.platform }}
126-
push: true
117+
containerfiles: Dockerfile.base
127118
tags: ${{ steps.meta_ci_base.outputs.tags }}
128119
labels: ${{ steps.meta_ci_base.outputs.labels }}
129120

130-
- name: Build CI docker image
131-
uses: docker/build-push-action@v3
132-
with:
133-
context: .
134-
file: Dockerfile.ci
135-
platforms: ${{ matrix.variant.platform }}
136-
push: true
137-
tags: ${{ steps.meta_ci.outputs.tags }}
138-
labels: ${{ steps.meta_ci.outputs.labels }}
139-
build-args: |
140-
BASE_IMAGE=localhost:5000/zephyrproject-rtos/ci-base-testing:${{ steps.meta_ci_base.outputs.version }}
141-
142-
- name: Build Developer docker image
143-
uses: docker/build-push-action@v3
121+
# - name: Build CI image
122+
# uses: docker/build-push-action@v3
123+
# with:
124+
# context: .
125+
# file: Dockerfile.ci
126+
# platforms: ${{ matrix.variant.platform }}
127+
# push: true
128+
# tags: ${{ steps.meta_ci.outputs.tags }}
129+
# labels: ${{ steps.meta_ci.outputs.labels }}
130+
# build-args: |
131+
# BASE_IMAGE=localhost:5000/zephyrproject-rtos/ci-base-testing:${{ steps.meta_ci_base.outputs.version }}
132+
133+
# - name: Build Developer image
134+
# uses: docker/build-push-action@v3
135+
# with:
136+
# context: .
137+
# file: Dockerfile.devel
138+
# platforms: ${{ matrix.variant.platform }}
139+
# push: true
140+
# tags: ${{ steps.meta_developer.outputs.tags }}
141+
# labels: ${{ steps.meta_developer.outputs.labels }}
142+
# build-args: |
143+
# BASE_IMAGE=localhost:5000/zephyrproject-rtos/ci-testing:${{ steps.meta_ci.outputs.version }}
144+
145+
- name: Push base image
146+
uses: redhat-actions/push-to-registry@v2
144147
with:
145-
context: .
146-
file: Dockerfile.devel
147-
platforms: ${{ matrix.variant.platform }}
148-
push: true
149-
tags: ${{ steps.meta_developer.outputs.tags }}
150-
labels: ${{ steps.meta_developer.outputs.labels }}
151-
build-args: |
152-
BASE_IMAGE=localhost:5000/zephyrproject-rtos/ci-testing:${{ steps.meta_ci.outputs.version }}
153-
154-
- name: Login to DockerHub
155-
if: ${{ github.event_name != 'pull_request' }}
156-
uses: docker/login-action@v2
157-
with:
158-
registry: docker.io
159-
username: ${{ secrets.DOCKERHUB_USERNAME }}
160-
password: ${{ secrets.DOCKERHUB_TOKEN }}
161-
162-
- name: Login to GitHub Container Registry
163-
if: ${{ github.event_name != 'pull_request' }}
164-
uses: docker/login-action@v2
165-
with:
166-
registry: ghcr.io
167-
username: ${{ github.repository_owner }}
168-
password: ${{ secrets.GITHUB_TOKEN }}
169-
170-
- name: Push base docker image
171-
if: ${{ github.event_name != 'pull_request' }}
172-
uses: stephanosio/[email protected]
173-
with:
174-
src: localhost:5000/zephyrproject-rtos/ci-base-testing:${{ steps.meta_ci_base.outputs.version }}
175-
dst: ${{ steps.meta_ci_base_push.outputs.tags }}
176-
177-
- name: Push CI docker image
178-
if: ${{ github.event_name != 'pull_request' }}
179-
uses: stephanosio/[email protected]
180-
with:
181-
src: localhost:5000/zephyrproject-rtos/ci-testing:${{ steps.meta_ci.outputs.version }}
182-
dst: ${{ steps.meta_ci_push.outputs.tags }}
183-
184-
- name: Push Developer docker image
185-
if: ${{ github.event_name != 'pull_request' }}
186-
uses: stephanosio/[email protected]
187-
with:
188-
src: localhost:5000/zephyrproject-rtos/zephyr-build-testing:${{ steps.meta_developer.outputs.version }}
189-
dst: ${{ steps.meta_developer_push.outputs.tags }}
148+
tags: ${{ steps.meta_ci_base.outputs.tags }}
190149

191150
merge:
192151
name: Merge
193152
runs-on:
194153
group: zephyr-runner-v2-linux-x64-4xlarge
154+
container:
155+
image: ghcr.io/zephyrproject-rtos/image-build:v1.0.0
195156
needs: build
196157
if: ${{ github.event_name != 'pull_request' }}
197158

198159
steps:
199160
- name: Login to DockerHub
200-
uses: docker/login-action@v2
161+
if: ${{ github.event_name != 'pull_request' }}
162+
uses: redhat-actions/podman-login@v1
201163
with:
202164
registry: docker.io
203-
username: ${{ secrets.DOCKERHUB_USERNAME }}
165+
username: ${{ vars.DOCKERHUB_USERNAME }}
204166
password: ${{ secrets.DOCKERHUB_TOKEN }}
205167

206168
- name: Login to GitHub Container Registry
207-
uses: docker/login-action@v2
169+
if: ${{ github.event_name != 'pull_request' }}
170+
uses: redhat-actions/podman-login@v1
208171
with:
209172
registry: ghcr.io
210173
username: ${{ github.repository_owner }}
211174
password: ${{ secrets.GITHUB_TOKEN }}
212175

213-
- name: Generate push metadata for base docker image
214-
id: meta_ci_base_push
176+
- name: Generate metadata for base image
177+
id: meta_ci_base
215178
uses: docker/metadata-action@v4
216179
with:
217180
images: |
218-
docker.io/zephyrprojectrtos/ci-base-testing
219-
ghcr.io/zephyrproject-rtos/ci-base-testing
181+
${{ env.DOCKERHUB_BASE }}/${{ env.BASE_IMAGE_NAME }}
182+
${{ env.GHCR_BASE }}/${{ env.BASE_IMAGE_NAME }}
220183
flavor: |
221184
latest=false
222185
tags: |
223186
type=ref,event=branch
224187
type=ref,event=tag
225188
type=raw,value=latest,enable={{is_default_branch}}
226189
227-
- name: Generate push metadata for CI image
228-
id: meta_ci_push
190+
- name: Generate metadata for CI image
191+
id: meta_ci
229192
uses: docker/metadata-action@v4
230193
with:
231194
images: |
232-
docker.io/zephyrprojectrtos/ci-testing
233-
ghcr.io/zephyrproject-rtos/ci-testing
195+
${{ env.DOCKERHUB_BASE }}/${{ env.CI_IMAGE_NAME }}
196+
${{ env.GHCR_BASE }}/${{ env.CI_IMAGE_NAME }}
234197
flavor: |
235198
latest=false
236199
tags: |
237200
type=ref,event=branch
238201
type=ref,event=tag
239202
type=raw,value=latest,enable={{is_default_branch}}
240203
241-
- name: Generate push metadata for Developer image
242-
id: meta_developer_push
204+
- name: Generate metadata for Developer image
205+
id: meta_developer
243206
uses: docker/metadata-action@v4
244207
with:
245208
images: |
246-
docker.io/zephyrprojectrtos/zephyr-build-testing
247-
ghcr.io/zephyrproject-rtos/zephyr-build-testing
209+
${{ env.DOCKERHUB_BASE }}/${{ env.DEVELOPER_IMAGE_NAME }}
210+
${{ env.GHCR_BASE }}/${{ env.DEVELOPER_IMAGE_NAME }}
248211
flavor: |
249212
latest=false
250213
tags: |
@@ -255,46 +218,46 @@ jobs:
255218
- name: Create multi-architecture image
256219
run: |
257220
archs=(amd64 arm64)
258-
ci_base_image="ghcr.io/zephyrproject-rtos/ci-base-testing:${{ steps.meta_ci_base_push.outputs.version }}"
259-
ci_image="ghcr.io/zephyrproject-rtos/ci-testing:${{ steps.meta_ci_push.outputs.version }}"
260-
developer_image="ghcr.io/zephyrproject-rtos/zephyr-build-testing:${{ steps.meta_developer_push.outputs.version }}"
221+
222+
ci_base_image_name="${{ env.BASE_IMAGE_NAME }}:${{ steps.meta_ci_base.outputs.version }}"
223+
ci_image_name="${{ env.CI_IMAGE_NAME }}:${{ steps.meta_ci.outputs.version }}"
224+
developer_image_name="${{ env.DEVELOPER_IMAGE_NAME }}:${{ steps.meta_developer.outputs.version }}"
225+
226+
ci_base_image="${{ env.GHCR_BASE }}/${ci_base_image_name}"
227+
ci_image="${{ env.GHCR_BASE }}/${ci_image_name}"
228+
developer_image="${{ env.GHCR_BASE }}/${developer_image_name}"
261229
262230
# Pull architecture-specific images
263231
for arch in ${archs[@]}; do
264-
docker pull ${ci_base_image}-${arch}
265-
docker pull ${ci_image}-${arch}
266-
docker pull ${developer_image}-${arch}
232+
podman pull ${ci_base_image}-${arch}
233+
# podman pull ${ci_image}-${arch}
234+
# podman pull ${developer_image}-${arch}
267235
done
268236
269-
# Create multi-architecture image
237+
# Create multi-architecture images
270238
for arch in ${archs[@]}; do
271239
ci_base_image_amend_flags+="--amend ${ci_base_image}-${arch} "
272240
ci_image_amend_flags+="--amend ${ci_image}-${arch} "
273241
developer_image_amend_flags+="--amend ${developer_image}-${arch} "
274242
done
275243
276-
docker manifest create ${ci_base_image} ${ci_base_image_amend_flags}
277-
docker manifest create ${ci_image} ${ci_image_amend_flags}
278-
docker manifest create ${developer_image} ${developer_image_amend_flags}
244+
podman manifest create ${ci_base_image} ${ci_base_image_amend_flags}
245+
# podman manifest create ${ci_image} ${ci_image_amend_flags}
246+
# podman manifest create ${developer_image} ${developer_image_amend_flags}
279247
280-
docker manifest push ${ci_base_image}
281-
docker manifest push ${ci_image}
282-
docker manifest push ${developer_image}
248+
# podman manifest push ${ci_base_image}
249+
# podman manifest push ${ci_image}
250+
# podman manifest push ${developer_image}
283251
284-
- name: Push base docker image
285-
uses: stephanosio/[email protected]
286-
with:
287-
src: ghcr.io/zephyrproject-rtos/ci-base-testing:${{ steps.meta_ci_base_push.outputs.version }}
288-
dst: ${{ steps.meta_ci_base_push.outputs.tags }}
252+
# Tag DockerHub multi-architecture images
253+
podman tag ${ci_base_image} ${{ env.DOCKERHUB_BASE }}/${ci_base_image_name}
254+
# podman tag ${ci_image} ${{ env.DOCKERHUB_BASE }}/${ci_image_name}
255+
# podman tag ${developer_image} ${{ env.DOCKERHUB_BASE }}/${developer_image_name}
289256
290-
- name: Push CI docker image
291-
uses: stephanosio/tag-push-action@v2.1.0
257+
- name: Push base image
258+
uses: redhat-actions/push-to-registry@v2
292259
with:
293-
src: ghcr.io/zephyrproject-rtos/ci-testing:${{ steps.meta_ci_push.outputs.version }}
294-
dst: ${{ steps.meta_ci_push.outputs.tags }}
260+
tags: ${{ steps.meta_ci_base.outputs.tags }}
295261

296-
- name: Push Developer docker image
297-
uses: stephanosio/[email protected]
298-
with:
299-
src: ghcr.io/zephyrproject-rtos/zephyr-build-testing:${{ steps.meta_developer_push.outputs.version }}
300-
dst: ${{ steps.meta_developer_push.outputs.tags }}
262+
# TODO: Push CI image
263+
# TODO: Push Developer image

0 commit comments

Comments
 (0)