Skip to content

Commit 6fbbe1c

Browse files
committed
try native runners
1 parent c7b16ed commit 6fbbe1c

File tree

1 file changed

+48
-22
lines changed

1 file changed

+48
-22
lines changed

.github/workflows/build.yml

Lines changed: 48 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,39 +14,38 @@ on:
1414
default: ""
1515

1616
jobs:
17-
setup-matrix:
18-
runs-on: ubuntu-latest
17+
setup-services:
18+
runs-on: ubuntu-24.04
1919
outputs:
20-
matrix: ${{ steps.set-matrix.outputs.matrix }}
20+
services: ${{ steps.set-services.outputs.services }}
2121
steps:
2222
- name: Checkout code
2323
uses: actions/checkout@v4
2424
with:
2525
token: ${{ secrets.GITHUB_TOKEN }}
2626

2727
- name: Set up matrix
28-
id: set-matrix
28+
id: set-services
2929
run: |
3030
if [ -n "${{ github.event.inputs.services }}" ]; then
3131
echo "Using provided services: ${{ github.event.inputs.services }}"
32-
SERVICES=$(echo "${{ github.event.inputs.services }}" | tr ',' '\n' | xargs -I {} echo '"{}"' | jq -s '.')
32+
SERVICES=$(echo "${{ github.event.inputs.services }}" | tr ',' '\n' | xargs -I {} echo '"{}"' | jq -c -s '.')
3333
else
3434
echo "Auto-detecting folders with Dockerfiles..."
35-
SERVICES=$(find . -maxdepth 2 -name Dockerfile -type f | cut -d/ -f2 | sort -u | jq -R . | jq -s '.')
35+
SERVICES=$(find . -maxdepth 2 -name Dockerfile -type f | cut -d/ -f2 | sort -u | jq -R . | jq -c -s '.')
3636
fi
3737
38-
MATRIX=$(echo "$SERVICES" | jq -c '{service: .}')
39-
echo "Matrix: $MATRIX"
40-
echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
38+
echo "services=$SERVICES" >> $GITHUB_OUTPUT
4139
4240
build:
4341
needs: setup-matrix
44-
runs-on: ubuntu-latest
42+
runs-on: ${{ matrix.arch == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
4543
strategy:
46-
matrix: ${{fromJson(needs.setup-matrix.outputs.matrix)}}
47-
fail-fast: false
44+
matrix:
45+
service: ${{ fromJson(needs.setup-services.outputs.services) }}
46+
arch: [amd64, arm64]
4847
steps:
49-
- name: Checkout code
48+
- name: Checkout code (sparse for service)
5049
uses: actions/checkout@v4
5150
with:
5251
token: ${{ secrets.GITHUB_TOKEN }}
@@ -58,26 +57,53 @@ jobs:
5857
run: |
5958
git submodule update --init --recursive ${{ matrix.service }}
6059
61-
- name: Set up QEMU
62-
uses: docker/setup-qemu-action@v3
63-
64-
- name: Set up Docker Buildx
65-
uses: docker/setup-buildx-action@v3
66-
6760
- name: Log in to GHCR
6861
uses: docker/login-action@v3
6962
with:
7063
registry: ghcr.io
7164
username: ${{ github.actor }}
7265
password: ${{ secrets.GITHUB_TOKEN }}
7366

74-
- name: Build and push Docker images
67+
- name: Set up Docker Buildx (required to use buildx imagetools)
68+
uses: docker/setup-buildx-action@v3
69+
with:
70+
driver: docker-container
71+
72+
- name: Build and push native image (per-arch)
7573
uses: docker/build-push-action@v4
7674
with:
7775
context: ${{ matrix.service }}
7876
file: ${{ matrix.service }}/Dockerfile
79-
platforms: linux/amd64,linux/arm64
77+
platforms: linux/${{ matrix.arch }}
8078
push: true
81-
tags: ghcr.io/${{ github.repository_owner }}/${{ matrix.service }}:latest
79+
tags: |
80+
ghcr.io/${{ github.repository_owner }}/${{ matrix.service }}:${{ matrix.arch }}-latest
8281
cache-from: type=gha
8382
cache-to: type=gha,mode=max
83+
84+
create-manifest:
85+
needs: build
86+
runs-on: ubuntu-24.04
87+
strategy:
88+
matrix:
89+
service: ${{ fromJson(needs.setup-matrix.outputs.matrix).service }}
90+
steps:
91+
- name: Log in to GHCR
92+
uses: docker/login-action@v3
93+
with:
94+
registry: ghcr.io
95+
username: ${{ github.actor }}
96+
password: ${{ secrets.GITHUB_TOKEN }}
97+
98+
- name: Set up Docker Buildx
99+
uses: docker/setup-buildx-action@v3
100+
with:
101+
driver: docker-container
102+
103+
- name: Create and push multi-arch manifest (imagetools)
104+
run: |
105+
AMD64_TAG="ghcr.io/${{ github.repository_owner }}/${{ matrix.service }}:amd64-latest"
106+
ARM64_TAG="ghcr.io/${{ github.repository_owner }}/${{ matrix.service }}:arm64-latest"
107+
MULTI_TAG="ghcr.io/${{ github.repository_owner }}/${{ matrix.service }}:latest"
108+
109+
docker buildx imagetools create --tag "$MULTI_TAG" "$AMD64_TAG" "$ARM64_TAG"

0 commit comments

Comments
 (0)