Skip to content

Commit f510d6c

Browse files
committed
ci: update build_container.yml for improved matrix handling and permissions
Signed-off-by: Robert Waffen <rw@betadots.de>
1 parent 4e39a33 commit f510d6c

1 file changed

Lines changed: 43 additions & 82 deletions

File tree

.github/workflows/build_container.yml

Lines changed: 43 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,64 @@
1+
---
12
name: Build and publish a 🛢️ container
23

34
on:
45
push:
56
branches:
67
- 'main'
78
tags:
8-
- '*'
9+
- 'v*'
910
workflow_dispatch:
1011

12+
concurrency:
13+
group: build-and-publish-${{ github.ref }}
14+
cancel-in-progress: true
15+
16+
permissions:
17+
contents: read # minimal required permissions to clone repo
18+
1119
jobs:
1220
setup-matrix:
1321
runs-on: ubuntu-latest
1422
outputs:
15-
matrix: ${{ steps.set-matrix.outputs.matrix }}
23+
build_matrix: ${{ steps.set-build-matrix.outputs.build_matrix }}
24+
tag_matrix: ${{ steps.set-tag-matrix.outputs.tag_matrix }}
1625
steps:
1726
- name: Source checkout
1827
uses: actions/checkout@v6
1928

2029
- name: 'Setup yq'
2130
uses: dcarbone/install-yq-action@v1.3.1
2231

23-
- id: set-matrix
24-
run: echo "matrix=$(yq -o json build_versions.yaml | jq -c)" >> $GITHUB_OUTPUT
32+
- id: set-build-matrix
33+
run: echo "build_matrix=$(bash matrix.sh build)" >> $GITHUB_OUTPUT
2534

26-
build-X86-container:
27-
runs-on: ubuntu-24.04
28-
permissions:
29-
contents: read
30-
packages: write
31-
needs: setup-matrix
32-
strategy:
33-
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
34-
steps:
35-
- name: Build OpenVox Server ${{ matrix.release }} container
36-
uses: voxpupuli/gha-build-and-publish-a-container@v2
37-
with:
38-
registry_password: ${{ secrets.GITHUB_TOKEN }}
39-
build_args: |
40-
OPENVOX_RELEASE=${{ matrix.release }}
41-
OPENVOXAGENT_VERSION=${{ matrix.agent_version }}
42-
build_arch: linux/amd64
43-
build_context: .
44-
buildfile: Containerfile
45-
tags: |
46-
ghcr.io/openvoxproject/openvoxagent:${{ matrix.release }}-${{ github.sha }}-x86_64
35+
- id: set-tag-matrix
36+
run: echo "tag_matrix=$(bash matrix.sh tag)" >> $GITHUB_OUTPUT
4737

48-
build-ARM-container:
49-
runs-on: ubuntu-24.04-arm
38+
build-and-push-container:
39+
runs-on: ${{ matrix.runner }}
5040
permissions:
5141
contents: read
5242
packages: write
5343
needs: setup-matrix
5444
strategy:
55-
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
45+
matrix: ${{ fromJson(needs.setup-matrix.outputs.build_matrix) }}
5646
steps:
57-
- name: Build OpenVox Server ${{ matrix.release }} container
47+
- name: Checkout repository
48+
uses: actions/checkout@v6
49+
50+
- name: Build ${{ matrix.platform }} container
5851
uses: voxpupuli/gha-build-and-publish-a-container@v2
5952
with:
6053
registry_password: ${{ secrets.GITHUB_TOKEN }}
6154
build_args: |
6255
OPENVOX_RELEASE=${{ matrix.release }}
6356
OPENVOXAGENT_VERSION=${{ matrix.agent_version }}
64-
build_arch: linux/arm64
57+
build_arch: linux/${{ matrix.platform }}
6558
build_context: .
6659
buildfile: Containerfile
67-
tags: |
68-
ghcr.io/openvoxproject/openvoxagent:${{ matrix.release }}-${{ github.sha }}-arm64
60+
# tag will look like: ghcr.io/openvoxproject/openvoxagent:8-<sha>-amd64
61+
tags: ghcr.io/openvoxproject/openvoxagent:${{ matrix.release }}-${{ github.sha }}-${{ matrix.platform }}
6962

7063
create-multi-arch-manifests:
7164
runs-on: ubuntu-latest
@@ -74,10 +67,9 @@ jobs:
7467
packages: write
7568
needs:
7669
- setup-matrix
77-
- build-X86-container
78-
- build-ARM-container
70+
- build-and-push-container
7971
strategy:
80-
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
72+
matrix: ${{ fromJson(needs.setup-matrix.outputs.tag_matrix) }}
8173
steps:
8274
- name: Log in to the ghcr.io registry
8375
uses: docker/login-action@v4
@@ -93,57 +85,26 @@ jobs:
9385
username: voxpupulibot
9486
password: ${{ secrets.DOCKERHUB_BOT_ADMIN_TOKEN }}
9587

96-
- name: Extract version number
97-
id: extract_version
98-
uses: actions/github-script@v9
99-
with:
100-
script: |
101-
const agentVersion = '${{ matrix.agent_version }}';
102-
const version = agentVersion.split('-')[0];
103-
core.setOutput('version', version);
104-
105-
- name: Create multi arch manifests
88+
- name: Create ref-specific multi-arch manifests
10689
run: |
107-
docker buildx imagetools create -t ghcr.io/openvoxproject/openvoxagent:${{ steps.extract_version.outputs.version }}-${{ github.ref_name }} \
108-
ghcr.io/openvoxproject/openvoxagent:${{ matrix.release }}-${{ github.sha }}-arm64 \
109-
ghcr.io/openvoxproject/openvoxagent:${{ matrix.release }}-${{ github.sha }}-x86_64
110-
111-
docker buildx imagetools create -t ghcr.io/openvoxproject/openvoxagent:${{ steps.extract_version.outputs.version }}-latest \
112-
ghcr.io/openvoxproject/openvoxagent:${{ matrix.release }}-${{ github.sha }}-arm64 \
113-
ghcr.io/openvoxproject/openvoxagent:${{ matrix.release }}-${{ github.sha }}-x86_64
114-
115-
docker buildx imagetools create -t ghcr.io/openvoxproject/openvoxagent:${{ matrix.release }}-latest \
116-
ghcr.io/openvoxproject/openvoxagent:${{ matrix.release }}-${{ github.sha }}-arm64 \
117-
ghcr.io/openvoxproject/openvoxagent:${{ matrix.release }}-${{ github.sha }}-x86_64
118-
119-
docker buildx imagetools create -t ghcr.io/openvoxproject/openvoxagent:${{ matrix.release }} \
120-
ghcr.io/openvoxproject/openvoxagent:${{ matrix.release }}-${{ github.sha }}-arm64 \
121-
ghcr.io/openvoxproject/openvoxagent:${{ matrix.release }}-${{ github.sha }}-x86_64
122-
123-
docker buildx imagetools create -t ghcr.io/openvoxproject/openvoxagent:latest \
90+
docker buildx imagetools create \
91+
-t ghcr.io/openvoxproject/openvoxagent:${{ matrix.agent_semver }}-${{ github.ref_name }} \
92+
-t ghcr.io/openvoxproject/openvoxagent:${{ matrix.agent_semver }} \
93+
-t ghcr.io/openvoxproject/openvoxagent:${{ matrix.release }} \
94+
-t docker.io/voxpupuli/openvoxagent:${{ matrix.agent_semver }}-${{ github.ref_name }} \
95+
-t docker.io/voxpupuli/openvoxagent:${{ matrix.agent_semver }} \
96+
-t docker.io/voxpupuli/openvoxagent:${{ matrix.release }} \
12497
ghcr.io/openvoxproject/openvoxagent:${{ matrix.release }}-${{ github.sha }}-arm64 \
125-
ghcr.io/openvoxproject/openvoxagent:${{ matrix.release }}-${{ github.sha }}-x86_64
98+
ghcr.io/openvoxproject/openvoxagent:${{ matrix.release }}-${{ github.sha }}-amd64
12699
127-
# on docker.io we use the voxpupuli namespace because new organizations are not free anymore
128-
docker buildx imagetools create -t docker.io/voxpupuli/openvoxagent:${{ steps.extract_version.outputs.version }}-${{ github.ref_name }} \
129-
ghcr.io/openvoxproject/openvoxagent:${{ matrix.release }}-${{ github.sha }}-arm64 \
130-
ghcr.io/openvoxproject/openvoxagent:${{ matrix.release }}-${{ github.sha }}-x86_64
131-
132-
docker buildx imagetools create -t docker.io/voxpupuli/openvoxagent:${{ steps.extract_version.outputs.version }}-latest \
133-
ghcr.io/openvoxproject/openvoxagent:${{ matrix.release }}-${{ github.sha }}-arm64 \
134-
ghcr.io/openvoxproject/openvoxagent:${{ matrix.release }}-${{ github.sha }}-x86_64
135-
136-
docker buildx imagetools create -t docker.io/voxpupuli/openvoxagent:${{ matrix.release }}-latest \
137-
ghcr.io/openvoxproject/openvoxagent:${{ matrix.release }}-${{ github.sha }}-arm64 \
138-
ghcr.io/openvoxproject/openvoxagent:${{ matrix.release }}-${{ github.sha }}-x86_64
139-
140-
docker buildx imagetools create -t docker.io/voxpupuli/openvoxagent:${{ matrix.release }} \
141-
ghcr.io/openvoxproject/openvoxagent:${{ matrix.release }}-${{ github.sha }}-arm64 \
142-
ghcr.io/openvoxproject/openvoxagent:${{ matrix.release }}-${{ github.sha }}-x86_64
143-
144-
docker buildx imagetools create -t docker.io/voxpupuli/openvoxagent:latest \
100+
- name: Update floating multi-arch tags
101+
if: github.ref == 'refs/heads/main'
102+
run: |
103+
docker buildx imagetools create \
104+
-t ghcr.io/openvoxproject/openvoxagent:latest \
105+
-t docker.io/voxpupuli/openvoxagent:latest \
145106
ghcr.io/openvoxproject/openvoxagent:${{ matrix.release }}-${{ github.sha }}-arm64 \
146-
ghcr.io/openvoxproject/openvoxagent:${{ matrix.release }}-${{ github.sha }}-x86_64
107+
ghcr.io/openvoxproject/openvoxagent:${{ matrix.release }}-${{ github.sha }}-amd64
147108
148109
update-dockerhub-description:
149110
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)