-
Notifications
You must be signed in to change notification settings - Fork 2
124 lines (111 loc) · 3.57 KB
/
Copy pathbuild-image.yml
File metadata and controls
124 lines (111 loc) · 3.57 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
116
117
118
119
120
121
122
123
124
name: Docker Build & Publish
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
meta:
name: Prepare metadata
runs-on: ubuntu-24.04
outputs:
datetime: ${{ steps.datetime.outputs.datetime }}
steps:
- name: Get current date and time
id: datetime
run: echo "datetime=$(date +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT
image-build:
name: Build and Push (${{ matrix.arch }})
needs: meta
strategy:
matrix:
include:
- arch: amd64
- arch: arm64
runs-on: ubuntu-24.04-arm
runs-on: ${{ matrix.runs-on || 'ubuntu-24.04' }}
permissions:
contents: read
actions: write
packages: write
steps:
- name: Check out repository code 🛎️
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Docker Buildx 🚀
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry 🚢
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ needs.meta.outputs.datetime }}
type=raw,value=latest
type=sha
type=ref,event=branch
type=ref,event=tag
flavor: |
suffix=-${{ matrix.arch }}
- name: Build and push 🏗️
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/${{ matrix.arch }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=${{ matrix.arch }}
cache-to: type=gha,mode=max,scope=${{ matrix.arch }}
build-args: |
NEXT_PUBLIC_APP_URL=${{ secrets.NEXT_PUBLIC_APP_URL }}
NEXT_PUBLIC_OPEN_SOURCE_URL=${{ secrets.NEXT_PUBLIC_OPEN_SOURCE_URL }}
NEXT_PUBLIC_DEFAULT_LOCALE=${{ secrets.NEXT_PUBLIC_DEFAULT_LOCALE }}
merge:
name: Create multi-arch manifest
needs: [meta, image-build]
if: ${{ github.event_name != 'pull_request' }}
runs-on: ubuntu-24.04
permissions:
contents: read
packages: write
steps:
- name: Set up Docker Buildx 🚀
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry 🚢
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=${{ needs.meta.outputs.datetime }}
type=sha
type=ref,event=branch
type=ref,event=tag
flavor: |
latest=true
- name: Create manifest list
run: |
tags="${{ steps.meta.outputs.tags }}"
for tag in $tags; do
docker buildx imagetools create -t "$tag" "${tag}-amd64" "${tag}-arm64"
done
docker buildx imagetools inspect "$tag"