Skip to content

Commit ced2d38

Browse files
author
Janis Erdmanis
committed
adding ci
1 parent fdfe787 commit ced2d38

1 file changed

Lines changed: 141 additions & 0 deletions

File tree

.github/workflows/ci.yml

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
name: CI
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
- dev
9+
paths-ignore:
10+
- "docs/**"
11+
12+
# only run the latest commit to avoid cache overwrites
13+
concurrency:
14+
group: ${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
env:
18+
REGISTRY: ghcr.io
19+
20+
jobs:
21+
amd64_build:
22+
runs-on: ubuntu-22.04
23+
name: AMD64 Build
24+
permissions:
25+
contents: read
26+
packages: write
27+
steps:
28+
- name: Check out code
29+
uses: actions/checkout@v4
30+
with:
31+
persist-credentials: false
32+
33+
- name: Create short sha
34+
run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV
35+
36+
- name: Lowercase repository name
37+
id: repo
38+
run: echo "name=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT
39+
40+
- name: Set up Podman
41+
run: |
42+
sudo apt-get update
43+
sudo apt-get install -y podman
44+
45+
- name: Log in to Container Registry
46+
run: |
47+
echo "${{ secrets.GITHUB_TOKEN }}" | podman login ${{ env.REGISTRY }} -u ${{ github.actor }} --password-stdin
48+
49+
- name: Build AMD64 image
50+
run: |
51+
podman build \
52+
--file ./Containerfile \
53+
--tag ${{ env.REGISTRY }}/${{ steps.repo.outputs.name }}:${{ env.SHORT_SHA }}-amd64 \
54+
.
55+
56+
- name: Push AMD64 image
57+
run: |
58+
podman push ${{ env.REGISTRY }}/${{ steps.repo.outputs.name }}:${{ env.SHORT_SHA }}-amd64
59+
60+
arm64_build:
61+
runs-on: ubuntu-22.04-arm64
62+
name: ARM64 Build
63+
permissions:
64+
contents: read
65+
packages: write
66+
steps:
67+
- name: Check out code
68+
uses: actions/checkout@v4
69+
with:
70+
persist-credentials: false
71+
72+
- name: Create short sha
73+
run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV
74+
75+
- name: Lowercase repository name
76+
id: repo
77+
run: echo "name=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT
78+
79+
- name: Set up Podman
80+
run: |
81+
sudo apt-get update
82+
sudo apt-get install -y podman
83+
84+
- name: Log in to Container Registry
85+
run: |
86+
echo "${{ secrets.GITHUB_TOKEN }}" | podman login ${{ env.REGISTRY }} -u ${{ github.actor }} --password-stdin
87+
88+
- name: Build ARM64 image
89+
run: |
90+
podman build \
91+
--file ./Containerfile \
92+
--tag ${{ env.REGISTRY }}/${{ steps.repo.outputs.name }}:${{ env.SHORT_SHA }}-arm64 \
93+
.
94+
95+
- name: Push ARM64 image
96+
run: |
97+
podman push ${{ env.REGISTRY }}/${{ steps.repo.outputs.name }}:${{ env.SHORT_SHA }}-arm64
98+
99+
assemble_manifest:
100+
runs-on: ubuntu-22.04
101+
name: Assemble multi-arch manifest
102+
needs:
103+
- amd64_build
104+
- arm64_build
105+
permissions:
106+
contents: read
107+
packages: write
108+
steps:
109+
- name: Create short sha
110+
run: echo "SHORT_SHA=${GITHUB_SHA::7}" >> $GITHUB_ENV
111+
112+
- name: Lowercase repository name
113+
id: repo
114+
run: echo "name=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT
115+
116+
- name: Set up Podman
117+
run: |
118+
sudo apt-get update
119+
sudo apt-get install -y podman
120+
121+
- name: Log in to Container Registry
122+
run: |
123+
echo "${{ secrets.GITHUB_TOKEN }}" | podman login ${{ env.REGISTRY }} -u ${{ github.actor }} --password-stdin
124+
125+
- name: Create and push multi-arch manifest
126+
run: |
127+
# Create manifest with short SHA
128+
podman manifest create ${{ env.REGISTRY }}/${{ steps.repo.outputs.name }}:${{ env.SHORT_SHA }}
129+
podman manifest add ${{ env.REGISTRY }}/${{ steps.repo.outputs.name }}:${{ env.SHORT_SHA }} \
130+
${{ env.REGISTRY }}/${{ steps.repo.outputs.name }}:${{ env.SHORT_SHA }}-amd64
131+
podman manifest add ${{ env.REGISTRY }}/${{ steps.repo.outputs.name }}:${{ env.SHORT_SHA }} \
132+
${{ env.REGISTRY }}/${{ steps.repo.outputs.name }}:${{ env.SHORT_SHA }}-arm64
133+
podman manifest push ${{ env.REGISTRY }}/${{ steps.repo.outputs.name }}:${{ env.SHORT_SHA }}
134+
135+
# Create manifest with latest tag
136+
podman manifest create ${{ env.REGISTRY }}/${{ steps.repo.outputs.name }}:latest
137+
podman manifest add ${{ env.REGISTRY }}/${{ steps.repo.outputs.name }}:latest \
138+
${{ env.REGISTRY }}/${{ steps.repo.outputs.name }}:${{ env.SHORT_SHA }}-amd64
139+
podman manifest add ${{ env.REGISTRY }}/${{ steps.repo.outputs.name }}:latest \
140+
${{ env.REGISTRY }}/${{ steps.repo.outputs.name }}:${{ env.SHORT_SHA }}-arm64
141+
podman manifest push ${{ env.REGISTRY }}/${{ steps.repo.outputs.name }}:latest

0 commit comments

Comments
 (0)