Skip to content

Commit adeaf5e

Browse files
committed
[+] add workflow
1 parent 5c8434c commit adeaf5e

1 file changed

Lines changed: 90 additions & 0 deletions

File tree

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Build and Push Docker Image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths-ignore:
8+
- 'readme.md'
9+
workflow_dispatch:
10+
11+
jobs:
12+
build:
13+
name: Build ${{ matrix.arch }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
arch: [ x86_64, aarch64 ]
18+
runs-on: ${{ matrix.arch == 'aarch64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v6
23+
24+
- name: Log in to GitHub Container Registry
25+
uses: redhat-actions/podman-login@v1
26+
with:
27+
registry: ghcr.io
28+
username: ${{ github.actor }}
29+
password: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Build Container image
32+
uses: redhat-actions/buildah-build@v2
33+
with:
34+
image: ghcr.io/${{ github.repository }}
35+
tags: ci-${{ matrix.arch }}
36+
containerfiles: ./dockerfile
37+
38+
- name: Save OCI archive
39+
run: |
40+
mkdir -p out
41+
podman save --format oci-archive -o "out/${{ matrix.arch }}.tar" "ghcr.io/${{ github.repository }}:ci-${{ matrix.arch }}"
42+
43+
- name: Upload OCI archive
44+
uses: actions/upload-artifact@v7
45+
with:
46+
name: image-${{ matrix.arch }}
47+
path: out/${{ matrix.arch }}.tar
48+
retention-days: 1
49+
compression-level: 0
50+
51+
manifest:
52+
name: Manifest push
53+
needs: build
54+
runs-on: ubuntu-latest
55+
56+
steps:
57+
- name: Download OCI archives
58+
uses: actions/download-artifact@v8
59+
with:
60+
pattern: image-*
61+
path: in
62+
merge-multiple: true
63+
64+
- name: Load images into local storage
65+
run: |
66+
set -euo pipefail
67+
for arch in x86_64 aarch64; do
68+
podman load -i "in/${arch}.tar"
69+
done
70+
71+
- name: Log in to GitHub Container Registry
72+
uses: redhat-actions/podman-login@v1
73+
with:
74+
registry: ghcr.io
75+
username: ${{ github.actor }}
76+
password: ${{ secrets.GITHUB_TOKEN }}
77+
78+
- name: Create & push multi-arch tags
79+
run: |
80+
set -euxo pipefail
81+
IMAGE="ghcr.io/${{ github.repository }}"
82+
AMD="${IMAGE}:ci-x86_64"
83+
ARM="${IMAGE}:ci-aarch64"
84+
t=latest
85+
86+
podman manifest rm "${IMAGE}:${t}" 2>/dev/null || true
87+
podman manifest create "${IMAGE}:${t}"
88+
podman manifest add "${IMAGE}:${t}" "containers-storage:${AMD}"
89+
podman manifest add "${IMAGE}:${t}" "containers-storage:${ARM}"
90+
podman manifest push --all "${IMAGE}:${t}" "docker://${IMAGE}:${t}"

0 commit comments

Comments
 (0)