Skip to content

Commit 657808e

Browse files
committed
Update build.yaml
1 parent 6d848bb commit 657808e

1 file changed

Lines changed: 52 additions & 18 deletions

File tree

.github/workflows/build.yaml

Lines changed: 52 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: build docker image
1+
name: build docker on push
22

33
on:
44
push:
@@ -10,12 +10,22 @@ permissions:
1010
packages: write
1111

1212
env:
13-
IMAGE: govdbot/migrate:latest
14-
GHCR_IMAGE: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:latest
13+
IMAGE: govdbot/${{ github.event.repository.name }}:${{ github.ref_name }}
14+
GHCR_IMAGE: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}:${{ github.ref_name }}
1515

1616
jobs:
17-
build:
18-
runs-on: ubuntu-24.04
17+
build-images:
18+
strategy:
19+
matrix:
20+
arch: [amd64, arm64]
21+
include:
22+
- arch: amd64
23+
platform: linux/amd64
24+
runner: ubuntu-24.04
25+
- arch: arm64
26+
platform: linux/arm64
27+
runner: ubuntu-24.04-arm
28+
runs-on: ${{ matrix.runner }}
1929
steps:
2030
- name: Checkout
2131
uses: actions/checkout@v4
@@ -36,24 +46,48 @@ jobs:
3646
username: ${{ github.repository_owner }}
3747
password: ${{ secrets.GITHUB_TOKEN }}
3848

39-
- name: Build and push multi-arch image to Docker Hub
49+
- name: Build and push ${{ matrix.arch }} image
4050
uses: docker/build-push-action@v6
4151
with:
52+
cache-from: type=gha
53+
cache-to: type=gha,mode=max
4254
context: .
43-
file: ./Dockerfile
55+
platforms: ${{ matrix.platform }}
4456
push: true
45-
platforms: linux/amd64,linux/arm64
57+
file: ./Dockerfile
58+
tags: |
59+
${{ env.IMAGE }}-${{ matrix.arch }}
60+
${{ env.GHCR_IMAGE }}-${{ matrix.arch }}
61+
62+
push-manifest:
63+
needs: [build-images]
64+
runs-on: ubuntu-latest
65+
steps:
66+
- name: Login to Docker Hub
67+
uses: docker/login-action@v3
68+
with:
69+
username: ${{ secrets.DOCKERHUB_USERNAME }}
70+
password: ${{ secrets.DOCKERHUB_TOKEN }}
71+
72+
- name: Login to GitHub Container Registry
73+
uses: docker/login-action@v3
74+
with:
75+
registry: ghcr.io
76+
username: ${{ github.repository_owner }}
77+
password: ${{ secrets.GITHUB_TOKEN }}
78+
79+
- name: Create tagged manifest
80+
uses: int128/docker-manifest-create-action@v2
81+
with:
4682
tags: ${{ env.IMAGE }}
47-
cache-from: type=gha
48-
cache-to: type=gha,mode=max
83+
sources: |
84+
${{ env.IMAGE }}-amd64
85+
${{ env.IMAGE }}-arm64
4986
50-
- name: Build and push multi-arch image to GHCR
51-
uses: docker/build-push-action@v6
87+
- name: Create tagged manifest for GitHub
88+
uses: int128/docker-manifest-create-action@v2
5289
with:
53-
context: .
54-
file: ./Dockerfile
55-
push: true
56-
platforms: linux/amd64,linux/arm64
5790
tags: ${{ env.GHCR_IMAGE }}
58-
cache-from: type=gha
59-
cache-to: type=gha,mode=max
91+
sources: |
92+
${{ env.GHCR_IMAGE }}-amd64
93+
${{ env.GHCR_IMAGE }}-arm64

0 commit comments

Comments
 (0)