-
Notifications
You must be signed in to change notification settings - Fork 33
189 lines (169 loc) · 7.32 KB
/
Build-Push-Containers.yml
File metadata and controls
189 lines (169 loc) · 7.32 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
name: Build Push Containers
on:
push:
branches:
- master
tags:
- '*'
schedule:
- cron: '0 0 1 * *' # 00:00 (UTC) on every 1st day of month.
env:
IMAGE_NAME: ctbcap
jobs:
build:
strategy:
matrix:
include: [
{ platform: 'linux/386', archname: 'x86', buildtype: 'minimal' },
{ platform: 'linux/amd64', archname: 'x86_64', buildtype: 'minimal' },
{ platform: 'linux/arm/v6', archname: 'armhf', buildtype: 'minimal' },
{ platform: 'linux/arm/v7', archname: 'armv7', buildtype: 'minimal' },
{ platform: 'linux/arm64/v8', archname: 'aarch64', buildtype: 'minimal' },
{ platform: 'linux/loong64', archname: 'loongarch64', buildtype: 'minimal' },
{ platform: 'linux/ppc64le', archname: 'ppc64le', buildtype: 'minimal' },
{ platform: 'linux/riscv64', archname: 'riscv64', buildtype: 'minimal' },
{ platform: 'linux/s390x', archname: 's390x', buildtype: 'fat' } # Free Actions Runner are not enough to run minimal build for s390x.
]
name: Build Container for ${{ matrix.platform }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: kfermercer
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Special Setup for Loongarch64
if: ${{ matrix.platform == 'linux/loong64' }}
run: |
docker run -t --rm --privileged ghcr.io/kfermercer/toolkit:loong64-qemu --reset -p yes
sed -i 's|FROM alpine:latest|FROM lcr.loongnix.cn/library/alpine:latest|g' ./Dockerfile
- name: Minimal build for ${{ matrix.archname }}
if: ${{ matrix.buildtype == 'minimal' }}
uses: docker/build-push-action@v6
with:
context: .
platforms: ${{ matrix.platform }}
provenance: false
push: true
tags: |
kfermercer/${{ env.IMAGE_NAME }}:latest-${{ matrix.archname }}
ghcr.io/kfermercer/${{ env.IMAGE_NAME }}:latest-${{ matrix.archname }}
target: minimal
- name: Fat build for ${{ matrix.archname }}
if: ${{ matrix.buildtype == 'fat' }}
uses: docker/build-push-action@v6
with:
build-args: BUILD_TARGET=fat
context: .
platforms: ${{ matrix.platform }}
provenance: false
push: true
tags: |
kfermercer/${{ env.IMAGE_NAME }}:latest-${{ matrix.archname }}
ghcr.io/kfermercer/${{ env.IMAGE_NAME }}:latest-${{ matrix.archname }}
target: fat
push:
name: Push merged manifests
runs-on: ubuntu-latest
needs: build
steps:
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: kfermercer
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}
- name: Create and push latest manifest image to Docker Hub
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
uses: Noelware/docker-manifest-action@v1
with:
tags: |
kfermercer/${{ env.IMAGE_NAME }}:latest,
kfermercer/${{ env.IMAGE_NAME }}:snapshot
inputs: |
kfermercer/${{ env.IMAGE_NAME }}:latest-x86,
kfermercer/${{ env.IMAGE_NAME }}:latest-x86_64,
kfermercer/${{ env.IMAGE_NAME }}:latest-armhf,
kfermercer/${{ env.IMAGE_NAME }}:latest-armv7,
kfermercer/${{ env.IMAGE_NAME }}:latest-aarch64,
kfermercer/${{ env.IMAGE_NAME }}:latest-loongarch64,
kfermercer/${{ env.IMAGE_NAME }}:latest-ppc64le,
kfermercer/${{ env.IMAGE_NAME }}:latest-riscv64,
kfermercer/${{ env.IMAGE_NAME }}:latest-s390x
push: true
- name: Create and push latest manifest image to GHCR
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
uses: Noelware/docker-manifest-action@v1
with:
tags: |
ghcr.io/kfermercer/${{ env.IMAGE_NAME }}:latest,
ghcr.io/kfermercer/${{ env.IMAGE_NAME }}:snapshot
inputs: |
ghcr.io/kfermercer/${{ env.IMAGE_NAME }}:latest-x86,
ghcr.io/kfermercer/${{ env.IMAGE_NAME }}:latest-x86_64,
ghcr.io/kfermercer/${{ env.IMAGE_NAME }}:latest-armhf,
ghcr.io/kfermercer/${{ env.IMAGE_NAME }}:latest-armv7,
ghcr.io/kfermercer/${{ env.IMAGE_NAME }}:latest-aarch64,
ghcr.io/kfermercer/${{ env.IMAGE_NAME }}:latest-loongarch64,
ghcr.io/kfermercer/${{ env.IMAGE_NAME }}:latest-ppc64le,
ghcr.io/kfermercer/${{ env.IMAGE_NAME }}:latest-riscv64,
ghcr.io/kfermercer/${{ env.IMAGE_NAME }}:latest-s390x
push: true
- name: Store release version to env
if: ${{ startsWith(github.ref, 'refs/tags/') }}
run: echo "RELEASE_VERSION=${GITHUB_REF:10}" >> $GITHUB_ENV
- name: Create and push release manifest to Docker Hub
if: ${{ startsWith(github.ref, 'refs/tags/') }}
uses: Noelware/docker-manifest-action@v1
with:
tags: |
kfermercer/${{ env.IMAGE_NAME }}:latest,
kfermercer/${{ env.IMAGE_NAME }}:latest-release,
kfermercer/${{ env.IMAGE_NAME }}:${{ env.RELEASE_VERSION }}
inputs: |
kfermercer/${{ env.IMAGE_NAME }}:latest-x86,
kfermercer/${{ env.IMAGE_NAME }}:latest-x86_64,
kfermercer/${{ env.IMAGE_NAME }}:latest-armhf,
kfermercer/${{ env.IMAGE_NAME }}:latest-armv7,
kfermercer/${{ env.IMAGE_NAME }}:latest-aarch64,
kfermercer/${{ env.IMAGE_NAME }}:latest-loongarch64,
kfermercer/${{ env.IMAGE_NAME }}:latest-ppc64le,
kfermercer/${{ env.IMAGE_NAME }}:latest-riscv64,
kfermercer/${{ env.IMAGE_NAME }}:latest-s390x
push: true
- name: Create and push release manifest to GHCR
if: ${{ startsWith(github.ref, 'refs/tags/') }}
uses: Noelware/docker-manifest-action@v1
with:
tags: |
ghcr.io/kfermercer/${{ env.IMAGE_NAME }}:latest,
ghcr.io/kfermercer/${{ env.IMAGE_NAME }}:latest-release,
ghcr.io/kfermercer/${{ env.IMAGE_NAME }}:${{ env.RELEASE_VERSION }}
inputs: |
ghcr.io/kfermercer/${{ env.IMAGE_NAME }}:latest-x86,
ghcr.io/kfermercer/${{ env.IMAGE_NAME }}:latest-x86_64,
ghcr.io/kfermercer/${{ env.IMAGE_NAME }}:latest-armhf,
ghcr.io/kfermercer/${{ env.IMAGE_NAME }}:latest-armv7,
ghcr.io/kfermercer/${{ env.IMAGE_NAME }}:latest-aarch64,
ghcr.io/kfermercer/${{ env.IMAGE_NAME }}:latest-loongarch64,
ghcr.io/kfermercer/${{ env.IMAGE_NAME }}:latest-ppc64le,
ghcr.io/kfermercer/${{ env.IMAGE_NAME }}:latest-riscv64,
ghcr.io/kfermercer/${{ env.IMAGE_NAME }}:latest-s390x
push: true