-
-
Notifications
You must be signed in to change notification settings - Fork 8
88 lines (85 loc) · 3.14 KB
/
build.yml
File metadata and controls
88 lines (85 loc) · 3.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: ci
on:
push:
branches:
- "main"
workflow_dispatch:
concurrency:
group: build
cancel-in-progress: true
jobs:
build-amd64:
runs-on: ubuntu-24.04
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Docker Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push AMD64 image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
platforms: linux/amd64
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/api:buildcache-amd64
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/api:buildcache-amd64,mode=max
tags: |
ghcr.io/${{ github.repository_owner }}/api:latest-amd64
ghcr.io/${{ github.repository_owner }}/api:${{ github.sha }}-amd64
build-arm64:
runs-on: ubuntu-24.04-arm
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Docker Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push ARM64 image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
platforms: linux/arm64
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/api:buildcache-arm64
cache-to: type=registry,ref=ghcr.io/${{ github.repository_owner }}/api:buildcache-arm64,mode=max
tags: |
ghcr.io/${{ github.repository_owner }}/api:latest-arm64
ghcr.io/${{ github.repository_owner }}/api:${{ github.sha }}-arm64
merge:
needs: [build-amd64, build-arm64]
runs-on: ubuntu-latest
steps:
- name: Log in to GitHub Docker Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create manifest list and push
run: |
docker buildx imagetools create -t ghcr.io/${{ github.repository_owner }}/api:latest \
ghcr.io/${{ github.repository_owner }}/api:latest-amd64 \
ghcr.io/${{ github.repository_owner }}/api:latest-arm64
docker buildx imagetools create -t ghcr.io/${{ github.repository_owner }}/api:${{ github.sha }} \
ghcr.io/${{ github.repository_owner }}/api:${{ github.sha }}-amd64 \
ghcr.io/${{ github.repository_owner }}/api:${{ github.sha }}-arm64
- name: Delete Package Versions
uses: actions/delete-package-versions@v5
with:
package-name: api
package-type: container
min-versions-to-keep: 9
ignore-versions: '^buildcache-*'