-
Notifications
You must be signed in to change notification settings - Fork 113
115 lines (98 loc) · 2.88 KB
/
Copy pathpublish-container.yml
File metadata and controls
115 lines (98 loc) · 2.88 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: Publish Container
on:
push:
tags:
- "v*"
workflow_dispatch:
permissions:
contents: read
packages: write
env:
IMAGE_GHCR: ghcr.io/${{ github.repository }}
concurrency:
group: publish-container-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build and Push (${{ matrix.arch }})
runs-on: ${{ matrix.runner }}
timeout-minutes: 180
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
platform: linux/amd64
runner: ubuntu-24.04
- arch: arm64
platform: linux/arm64
runner: ubuntu-24.04-arm
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Compute image metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.IMAGE_GHCR }}
flavor: |
latest=false
suffix=-${{ matrix.arch }}
tags: |
type=ref,event=tag
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
- name: Build and push arch image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
platforms: ${{ matrix.platform }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=container-${{ matrix.arch }}
cache-to: type=gha,mode=max,scope=container-${{ matrix.arch }}
publish:
name: Publish Multi-Arch Manifests
runs-on: ubuntu-24.04
timeout-minutes: 30
needs: build
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Compute image metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.IMAGE_GHCR }}
tags: |
type=ref,event=tag
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/v') }}
- name: Create and push manifest lists
shell: bash
run: |
set -euo pipefail
while IFS= read -r tag; do
[[ -z "$tag" ]] && continue
docker buildx imagetools create \
-t "$tag" \
"$tag-amd64" \
"$tag-arm64"
docker buildx imagetools inspect "$tag"
done <<< "${{ steps.meta.outputs.tags }}"