-
Notifications
You must be signed in to change notification settings - Fork 159
611 lines (548 loc) · 31.4 KB
/
docker-multi-arch.yml
File metadata and controls
611 lines (548 loc) · 31.4 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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
name: Docker Build
on:
push:
branches:
- main # 主分支有新 commit 时触发(合并 PR 后的 squash commit 在这里验)
tags:
- 'v*' # 匹配 v 开头的标签,例如 v1.0.0
paths-ignore:
- '**.md'
- 'docs/**'
- '.gitignore'
# PR 触发刻意不开:单个 PR 的多次 commit 会触发多次 multi-arch build,
# 200 PR/月 × N commit 占满 runner 队列;让 squash 进 main 的那次 push 来验证即可。
# 单 PR 想手动验,用 workflow_dispatch + ci 模式即可。
workflow_dispatch:
inputs:
build_mode:
description: '构建模式'
type: choice
options:
- ci
- custom
default: 'ci'
required: true
version:
description: '自定义版本号 (仅在 custom 模式下生效)'
required: false
default: ''
skip_dockerhub:
description: '跳过 Docker Hub 推送 (仅推送到 GHCR)'
type: boolean
required: false
default: false
# Concurrency configuration: queue Docker builds to avoid parallel runs
# - Same group for all triggers to ensure serialization
# - cancel-in-progress: false to wait for current build to complete
# - PR builds use separate group to not block main branch builds
concurrency:
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && 'main' || github.head_ref || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
REGISTRY_GHCR: ghcr.io
IMAGE_NAME: project-n-e-k-o/n.e.k.o
# Embedding model pin (kept identical to .github/workflows/build-desktop.yml and
# docker/Dockerfile{,.full} ARG defaults). The weights are pre-fetched on the
# native runner and cached so the Docker build never hits huggingface.co — see
# the "Prepare embedding model" steps below and Dockerfile step 6b.
EMBEDDING_MODEL_REPO: jinaai/jina-embeddings-v5-text-nano-retrieval
EMBEDDING_MODEL_PROFILE_ID: local-text-retrieval-v1
EMBEDDING_MODEL_REVISION: ac5d898c8d382b17167c33e5c8af644a3519b47d
jobs:
# ============================================================================
# Job 1: Calculate version (shared by all build jobs)
# ============================================================================
calculate-version:
runs-on: ubuntu-latest
outputs:
image_version: ${{ steps.version_calc.outputs.VERSION }}
skip_dockerhub: ${{ steps.calc_skip.outputs.SKIP_DOCKERHUB }}
is_main_commit: ${{ steps.calc_is_main.outputs.IS_MAIN_COMMIT }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Calculate is_main_commit flag
id: calc_is_main
run: |
# True for: main branch push OR manual dispatch from main branch in CI mode
# 必须同时锁定 ref==main,否则在 feature branch 上手动 dispatch ci 模式
# 会让 ci-standard/ci-full 等共享别名被未合并代码覆盖
if [[ "$GITHUB_REF" == refs/heads/main ]] && [[ "$GITHUB_EVENT_NAME" == "push" ]]; then
echo "IS_MAIN_COMMIT=true" >> $GITHUB_OUTPUT
elif [[ "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]] && [[ "${{ github.event.inputs.build_mode }}" == "ci" ]] && [[ "$GITHUB_REF" == refs/heads/main ]]; then
echo "IS_MAIN_COMMIT=true" >> $GITHUB_OUTPUT
else
echo "IS_MAIN_COMMIT=false" >> $GITHUB_OUTPUT
fi
- name: Calculate skip_dockerhub flag
id: calc_skip
run: |
# 策略:Docker Hub 只发 release(tag push)和手动 dispatch(按 input)。
# 主线 commit / PR(如果重新启用)只推 GHCR,避免主线滚动版污染对外 channel。
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "SKIP_DOCKERHUB=${{ github.event.inputs.skip_dockerhub || 'false' }}" >> $GITHUB_OUTPUT
elif [[ "$GITHUB_REF" == refs/tags/* ]]; then
# Release tag: 推 Docker Hub 作为对外公开发布 channel
echo "SKIP_DOCKERHUB=false" >> $GITHUB_OUTPUT
else
# 其他(main push / PR 等): 只推 GHCR
echo "SKIP_DOCKERHUB=true" >> $GITHUB_OUTPUT
fi
- name: Calculate Docker image version
id: version_calc
run: |
# 策略1: 如果是由 git tag 触发,则使用 tag 作为版本号 (去掉 'v' 前缀)
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
echo "版本号来源于Git标签: $VERSION"
# 策略2: 如果手动触发且选择 CI 模式,使用 ci-{commit hash} 格式
elif [[ "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]] && [[ "${{ github.event.inputs.build_mode }}" == "ci" ]]; then
COMMIT_SHORT=$(git rev-parse --short HEAD)
VERSION="ci-${COMMIT_SHORT}"
echo "版本号来源于CI模式(手动触发): $VERSION"
# 策略3: 如果手动触发且选择 custom 模式,使用自定义版本号
elif [[ "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]] && [[ "${{ github.event.inputs.build_mode }}" == "custom" ]]; then
VERSION="${{ github.event.inputs.version }}"
if [ -z "$VERSION" ] || [ "$VERSION" = "" ]; then
COMMIT_SHORT=$(git rev-parse --short HEAD)
DATE=$(date +%Y%m%d)
VERSION="${DATE}-${COMMIT_SHORT}"
echo "版本号为自动生成(未提供自定义版本): $VERSION"
else
echo "版本号来源于手动输入: $VERSION"
fi
# 策略4: 如果是 PR 触发,使用 pr-{number}-ci 标签
elif [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
PR_NUMBER=${{ github.event.pull_request.number }}
VERSION="pr-${PR_NUMBER}-ci"
echo "版本号来源于PR编号: $VERSION"
# 策略5: 如果是 main 分支 commit,使用 ci-{commit hash} 格式
elif [[ "$GITHUB_REF" == refs/heads/main ]]; then
COMMIT_SHORT=$(git rev-parse --short HEAD)
VERSION="ci-${COMMIT_SHORT}"
echo "版本号来源于main分支commit: $VERSION"
# 策略6: 其他情况,生成基于日期和提交哈希的版本号
else
COMMIT_SHORT=$(git rev-parse --short HEAD)
DATE=$(date +%Y%m%d)
VERSION="${DATE}-${COMMIT_SHORT}"
echo "版本号为自动生成: $VERSION"
fi
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
# ============================================================================
# Job 2: Build and push STANDARD version (parallel with full version)
# ============================================================================
build-standard:
needs: calculate-version
# 仅在上游仓库运行:fork 上的 push / workflow_dispatch 用其 GITHUB_TOKEN 无法写入上游 GHCR namespace,会必然失败
if: github.repository == 'Project-N-E-K-O/N.E.K.O' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
outputs:
skipped: ${{ steps.check-dockerfile.outputs.skipped }}
strategy:
matrix:
platform: [linux/amd64, linux/arm64]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
# Pre-fetch the embedding weights on the native runner and cache them by
# revision, so the (QEMU-emulated, throttle-prone) Docker build below never
# touches huggingface.co. Cache hit -> the downloader is a no-op; only a
# cold cache (revision bump / 7-day eviction) actually downloads, natively,
# once. The weights ride into the build via the context (Dockerfile 6b).
# Standard image ships int8 only to stay lightweight.
- name: Cache embedding model weights (int8)
uses: actions/cache@v4
with:
path: data/embedding_models
key: embedding-model-${{ env.EMBEDDING_MODEL_REVISION }}-int8
- name: Prepare embedding model assets (int8)
run: |
python3 scripts/prepare_embedding_model.py \
--repo "$EMBEDDING_MODEL_REPO" \
--revision "$EMBEDDING_MODEL_REVISION" \
--profile-id "$EMBEDDING_MODEL_PROFILE_ID" \
--output-root data/embedding_models \
--variant int8
- name: Check if Dockerfile exists
id: check-dockerfile
run: |
if [ -f "./docker/Dockerfile" ]; then
echo "skipped=false" >> $GITHUB_OUTPUT
echo "✅ docker/Dockerfile found, proceeding with standard build"
else
echo "skipped=true" >> $GITHUB_OUTPUT
echo "⚠️ docker/Dockerfile not found, skipping standard build"
fi
- name: Set up QEMU
if: steps.check-dockerfile.outputs.skipped != 'true'
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
if: steps.check-dockerfile.outputs.skipped != 'true'
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
if: steps.check-dockerfile.outputs.skipped != 'true'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Check Docker Hub credentials
id: check_dockerhub
if: steps.check-dockerfile.outputs.skipped != 'true' && needs.calculate-version.outputs.skip_dockerhub != 'true'
run: |
if [ -n "${{ secrets.DOCKERHUB_USERNAME }}" ] && [ -n "${{ secrets.DOCKERHUB_TOKEN }}" ]; then
echo "has_credentials=true" >> $GITHUB_OUTPUT
echo "✅ Docker Hub credentials found"
else
echo "has_credentials=false" >> $GITHUB_OUTPUT
echo "⚠️ Docker Hub credentials not configured, skipping Docker Hub push"
echo " To enable Docker Hub push, set DOCKERHUB_USERNAME and DOCKERHUB_TOKEN in repository secrets"
fi
- name: Log in to Docker Hub
if: steps.check-dockerfile.outputs.skipped != 'true' && needs.calculate-version.outputs.skip_dockerhub != 'true' && steps.check_dockerhub.outputs.has_credentials == 'true'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata for Docker (GHCR only)
if: steps.check-dockerfile.outputs.skipped != 'true' && (needs.calculate-version.outputs.skip_dockerhub == 'true' || (needs.calculate-version.outputs.skip_dockerhub != 'true' && steps.check_dockerhub.outputs.has_credentials != 'true'))
id: meta_ghcr
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_GHCR }}/${{ env.IMAGE_NAME }}
flavor: |
suffix=-${{ matrix.platform }}
tags: |
# PR builds: pr-{number}-ci-standard-linux-amd64/arm64 AND pr-ci-standard-linux-amd64/arm64
type=raw,value=${{ needs.calculate-version.outputs.image_version }}-standard,enable=${{ startsWith(needs.calculate-version.outputs.image_version, 'pr-') }}
type=raw,value=pr-ci-standard,enable=${{ startsWith(needs.calculate-version.outputs.image_version, 'pr-') }}
# CI builds: ci-{hash}-standard-linux-amd64/arm64 AND ci-standard-linux-amd64/arm64
type=raw,value=${{ needs.calculate-version.outputs.image_version }}-standard,enable=${{ startsWith(needs.calculate-version.outputs.image_version, 'ci-') }}
type=raw,value=ci-standard,enable=${{ startsWith(needs.calculate-version.outputs.image_version, 'ci-') }}
# Other builds (manual/tag): use version as-is
type=raw,value=${{ needs.calculate-version.outputs.image_version }}-standard,enable=${{ !startsWith(needs.calculate-version.outputs.image_version, 'pr-') && !startsWith(needs.calculate-version.outputs.image_version, 'ci-') }}
- name: Extract metadata for Docker (both registries)
if: steps.check-dockerfile.outputs.skipped != 'true' && needs.calculate-version.outputs.skip_dockerhub != 'true' && steps.check_dockerhub.outputs.has_credentials == 'true'
id: meta_both
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY_GHCR }}/${{ env.IMAGE_NAME }}
${{ secrets.DOCKERHUB_USERNAME }}/n.e.k.o
flavor: |
suffix=-${{ matrix.platform }}
tags: |
# PR builds: pr-{number}-ci-standard-linux-amd64/arm64 AND pr-ci-standard-linux-amd64/arm64
type=raw,value=${{ needs.calculate-version.outputs.image_version }}-standard,enable=${{ startsWith(needs.calculate-version.outputs.image_version, 'pr-') }}
type=raw,value=pr-ci-standard,enable=${{ startsWith(needs.calculate-version.outputs.image_version, 'pr-') }}
# CI builds: ci-{hash}-standard-linux-amd64/arm64 AND ci-standard-linux-amd64/arm64
type=raw,value=${{ needs.calculate-version.outputs.image_version }}-standard,enable=${{ startsWith(needs.calculate-version.outputs.image_version, 'ci-') }}
type=raw,value=ci-standard,enable=${{ startsWith(needs.calculate-version.outputs.image_version, 'ci-') }}
# Other builds (manual/tag): use version as-is
type=raw,value=${{ needs.calculate-version.outputs.image_version }}-standard,enable=${{ !startsWith(needs.calculate-version.outputs.image_version, 'pr-') && !startsWith(needs.calculate-version.outputs.image_version, 'ci-') }}
- name: Build and push standard image
if: steps.check-dockerfile.outputs.skipped != 'true'
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Dockerfile
platforms: ${{ matrix.platform }}
push: true
build-args: |
EMBEDDING_MODEL_REPO=${{ env.EMBEDDING_MODEL_REPO }}
EMBEDDING_MODEL_REVISION=${{ env.EMBEDDING_MODEL_REVISION }}
EMBEDDING_MODEL_PROFILE_ID=${{ env.EMBEDDING_MODEL_PROFILE_ID }}
tags: ${{ steps.meta_ghcr.outputs.tags || steps.meta_both.outputs.tags }}
labels: ${{ steps.meta_ghcr.outputs.labels || steps.meta_both.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
# ============================================================================
# Job 3: Build and push FULL version (parallel with standard version)
# ============================================================================
build-full:
needs: calculate-version
# 仅在上游仓库运行:fork 上的 push / workflow_dispatch 用其 GITHUB_TOKEN 无法写入上游 GHCR namespace,会必然失败
if: github.repository == 'Project-N-E-K-O/N.E.K.O' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
platform: [linux/amd64, linux/arm64]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
# Pre-fetch the embedding weights on the native runner and cache them by
# revision, so the (QEMU-emulated, throttle-prone) Docker build below never
# touches huggingface.co. Cache hit -> the downloader is a no-op; only a
# cold cache (revision bump / 7-day eviction) actually downloads, natively,
# once. The weights ride into the build via the context (Dockerfile.full
# 6b). Full image bundles both int8 and fp32.
- name: Cache embedding model weights (both)
uses: actions/cache@v4
with:
path: data/embedding_models
key: embedding-model-${{ env.EMBEDDING_MODEL_REVISION }}-both
- name: Prepare embedding model assets (both)
run: |
python3 scripts/prepare_embedding_model.py \
--repo "$EMBEDDING_MODEL_REPO" \
--revision "$EMBEDDING_MODEL_REVISION" \
--profile-id "$EMBEDDING_MODEL_PROFILE_ID" \
--output-root data/embedding_models \
--variant both
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- 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: Check Docker Hub credentials
id: check_dockerhub
if: needs.calculate-version.outputs.skip_dockerhub != 'true'
run: |
if [ -n "${{ secrets.DOCKERHUB_USERNAME }}" ] && [ -n "${{ secrets.DOCKERHUB_TOKEN }}" ]; then
echo "has_credentials=true" >> $GITHUB_OUTPUT
echo "✅ Docker Hub credentials found"
else
echo "has_credentials=false" >> $GITHUB_OUTPUT
echo "⚠️ Docker Hub credentials not configured, skipping Docker Hub push"
echo " To enable Docker Hub push, set DOCKERHUB_USERNAME and DOCKERHUB_TOKEN in repository secrets"
fi
- name: Log in to Docker Hub
if: needs.calculate-version.outputs.skip_dockerhub != 'true' && steps.check_dockerhub.outputs.has_credentials == 'true'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata for Docker (GHCR only)
if: needs.calculate-version.outputs.skip_dockerhub == 'true' || (needs.calculate-version.outputs.skip_dockerhub != 'true' && steps.check_dockerhub.outputs.has_credentials != 'true')
id: meta_ghcr
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_GHCR }}/${{ env.IMAGE_NAME }}
flavor: |
suffix=-${{ matrix.platform }}
tags: |
# PR builds: pr-{number}-ci-full-linux-amd64/arm64 AND pr-ci-full-linux-amd64/arm64
type=raw,value=${{ needs.calculate-version.outputs.image_version }}-full,enable=${{ startsWith(needs.calculate-version.outputs.image_version, 'pr-') }}
type=raw,value=pr-ci-full,enable=${{ startsWith(needs.calculate-version.outputs.image_version, 'pr-') }}
# CI builds: ci-{hash}-full-linux-amd64/arm64 AND ci-full-linux-amd64/arm64
type=raw,value=${{ needs.calculate-version.outputs.image_version }}-full,enable=${{ startsWith(needs.calculate-version.outputs.image_version, 'ci-') }}
type=raw,value=ci-full,enable=${{ startsWith(needs.calculate-version.outputs.image_version, 'ci-') }}
# Other builds (manual/tag): use version as-is
type=raw,value=${{ needs.calculate-version.outputs.image_version }}-full,enable=${{ !startsWith(needs.calculate-version.outputs.image_version, 'pr-') && !startsWith(needs.calculate-version.outputs.image_version, 'ci-') }}
- name: Extract metadata for Docker (both registries)
if: needs.calculate-version.outputs.skip_dockerhub != 'true' && steps.check_dockerhub.outputs.has_credentials == 'true'
id: meta_both
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY_GHCR }}/${{ env.IMAGE_NAME }}
${{ secrets.DOCKERHUB_USERNAME }}/n.e.k.o
flavor: |
suffix=-${{ matrix.platform }}
tags: |
# PR builds: pr-{number}-ci-full-linux-amd64/arm64 AND pr-ci-full-linux-amd64/arm64
type=raw,value=${{ needs.calculate-version.outputs.image_version }}-full,enable=${{ startsWith(needs.calculate-version.outputs.image_version, 'pr-') }}
type=raw,value=pr-ci-full,enable=${{ startsWith(needs.calculate-version.outputs.image_version, 'pr-') }}
# CI builds: ci-{hash}-full-linux-amd64/arm64 AND ci-full-linux-amd64/arm64
type=raw,value=${{ needs.calculate-version.outputs.image_version }}-full,enable=${{ startsWith(needs.calculate-version.outputs.image_version, 'ci-') }}
type=raw,value=ci-full,enable=${{ startsWith(needs.calculate-version.outputs.image_version, 'ci-') }}
# Other builds (manual/tag): use version as-is
type=raw,value=${{ needs.calculate-version.outputs.image_version }}-full,enable=${{ !startsWith(needs.calculate-version.outputs.image_version, 'pr-') && !startsWith(needs.calculate-version.outputs.image_version, 'ci-') }}
- name: Build and push full image
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Dockerfile.full
platforms: ${{ matrix.platform }}
push: true
build-args: |
EMBEDDING_MODEL_REPO=${{ env.EMBEDDING_MODEL_REPO }}
EMBEDDING_MODEL_REVISION=${{ env.EMBEDDING_MODEL_REVISION }}
EMBEDDING_MODEL_PROFILE_ID=${{ env.EMBEDDING_MODEL_PROFILE_ID }}
tags: ${{ steps.meta_ghcr.outputs.tags || steps.meta_both.outputs.tags }}
labels: ${{ steps.meta_ghcr.outputs.labels || steps.meta_both.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
# ============================================================================
# Job 4: Create multi-arch manifests (runs after both versions are built)
# ============================================================================
create-manifests:
needs: [calculate-version, build-standard, build-full]
if: github.repository == 'Project-N-E-K-O/N.E.K.O' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && always() && needs.build-full.result == 'success'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Check Docker Hub credentials
id: check_dockerhub
if: needs.calculate-version.outputs.skip_dockerhub != 'true'
run: |
if [ -n "${{ secrets.DOCKERHUB_USERNAME }}" ] && [ -n "${{ secrets.DOCKERHUB_TOKEN }}" ]; then
echo "has_credentials=true" >> $GITHUB_OUTPUT
echo "✅ Docker Hub credentials found"
else
echo "has_credentials=false" >> $GITHUB_OUTPUT
echo "⚠️ Docker Hub credentials not configured, skipping Docker Hub manifest push"
fi
- name: Log in to Docker Hub
if: needs.calculate-version.outputs.skip_dockerhub != 'true' && steps.check_dockerhub.outputs.has_credentials == 'true'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Create and push multi-arch manifest for standard version (GHCR)
if: needs.build-standard.outputs.skipped != 'true'
run: |
VERSION=${{ needs.calculate-version.outputs.image_version }}
docker buildx imagetools create \
-t ghcr.io/${{ env.IMAGE_NAME }}:${VERSION}-standard \
ghcr.io/${{ env.IMAGE_NAME }}:${VERSION}-standard-linux-amd64 \
ghcr.io/${{ env.IMAGE_NAME }}:${VERSION}-standard-linux-arm64
- name: Create and push multi-arch manifest for standard version (DockerHub)
if: needs.build-standard.outputs.skipped != 'true' && needs.calculate-version.outputs.skip_dockerhub != 'true' && steps.check_dockerhub.outputs.has_credentials == 'true'
run: |
VERSION=${{ needs.calculate-version.outputs.image_version }}
docker buildx imagetools create \
-t ${{ secrets.DOCKERHUB_USERNAME }}/n.e.k.o:${VERSION}-standard \
${{ secrets.DOCKERHUB_USERNAME }}/n.e.k.o:${VERSION}-standard-linux-amd64 \
${{ secrets.DOCKERHUB_USERNAME }}/n.e.k.o:${VERSION}-standard-linux-arm64
- name: Create and push multi-arch manifest for full version (GHCR)
run: |
VERSION=${{ needs.calculate-version.outputs.image_version }}
docker buildx imagetools create \
-t ghcr.io/${{ env.IMAGE_NAME }}:${VERSION}-full \
ghcr.io/${{ env.IMAGE_NAME }}:${VERSION}-full-linux-amd64 \
ghcr.io/${{ env.IMAGE_NAME }}:${VERSION}-full-linux-arm64
- name: Create and push multi-arch manifest for full version (DockerHub)
if: needs.calculate-version.outputs.skip_dockerhub != 'true' && steps.check_dockerhub.outputs.has_credentials == 'true'
run: |
VERSION=${{ needs.calculate-version.outputs.image_version }}
docker buildx imagetools create \
-t ${{ secrets.DOCKERHUB_USERNAME }}/n.e.k.o:${VERSION}-full \
${{ secrets.DOCKERHUB_USERNAME }}/n.e.k.o:${VERSION}-full-linux-amd64 \
${{ secrets.DOCKERHUB_USERNAME }}/n.e.k.o:${VERSION}-full-linux-arm64
- name: Create and push CI short tags - standard (GHCR)
if: needs.calculate-version.outputs.is_main_commit == 'true' && needs.build-standard.outputs.skipped != 'true'
run: |
VERSION=${{ needs.calculate-version.outputs.image_version }}
# GHCR - ci-standard (without hash)
docker buildx imagetools create \
-t ghcr.io/${{ env.IMAGE_NAME }}:ci-standard \
ghcr.io/${{ env.IMAGE_NAME }}:${VERSION}-standard-linux-amd64 \
ghcr.io/${{ env.IMAGE_NAME }}:${VERSION}-standard-linux-arm64
- name: Create and push CI short tags - full (GHCR)
if: needs.calculate-version.outputs.is_main_commit == 'true'
run: |
VERSION=${{ needs.calculate-version.outputs.image_version }}
# GHCR - ci-full (without hash)
docker buildx imagetools create \
-t ghcr.io/${{ env.IMAGE_NAME }}:ci-full \
ghcr.io/${{ env.IMAGE_NAME }}:${VERSION}-full-linux-amd64 \
ghcr.io/${{ env.IMAGE_NAME }}:${VERSION}-full-linux-arm64
- name: Create and push CI short tags - standard (DockerHub)
if: needs.calculate-version.outputs.is_main_commit == 'true' && needs.build-standard.outputs.skipped != 'true' && needs.calculate-version.outputs.skip_dockerhub != 'true' && steps.check_dockerhub.outputs.has_credentials == 'true'
run: |
VERSION=${{ needs.calculate-version.outputs.image_version }}
# DockerHub - ci-standard (without hash)
docker buildx imagetools create \
-t ${{ secrets.DOCKERHUB_USERNAME }}/n.e.k.o:ci-standard \
${{ secrets.DOCKERHUB_USERNAME }}/n.e.k.o:${VERSION}-standard-linux-amd64 \
${{ secrets.DOCKERHUB_USERNAME }}/n.e.k.o:${VERSION}-standard-linux-arm64
- name: Create and push CI short tags - full (DockerHub)
if: needs.calculate-version.outputs.is_main_commit == 'true' && needs.calculate-version.outputs.skip_dockerhub != 'true' && steps.check_dockerhub.outputs.has_credentials == 'true'
run: |
VERSION=${{ needs.calculate-version.outputs.image_version }}
# DockerHub - ci-full (without hash)
docker buildx imagetools create \
-t ${{ secrets.DOCKERHUB_USERNAME }}/n.e.k.o:ci-full \
${{ secrets.DOCKERHUB_USERNAME }}/n.e.k.o:${VERSION}-full-linux-amd64 \
${{ secrets.DOCKERHUB_USERNAME }}/n.e.k.o:${VERSION}-full-linux-arm64
- name: Create and push PR short tags - standard (GHCR)
if: github.event_name == 'pull_request' && needs.build-standard.outputs.skipped != 'true'
run: |
VERSION=${{ needs.calculate-version.outputs.image_version }}
# GHCR - pr-ci-standard (without PR number)
docker buildx imagetools create \
-t ghcr.io/${{ env.IMAGE_NAME }}:pr-ci-standard \
ghcr.io/${{ env.IMAGE_NAME }}:${VERSION}-standard-linux-amd64 \
ghcr.io/${{ env.IMAGE_NAME }}:${VERSION}-standard-linux-arm64
- name: Create and push PR short tags - full (GHCR)
if: github.event_name == 'pull_request'
run: |
VERSION=${{ needs.calculate-version.outputs.image_version }}
# GHCR - pr-ci-full (without PR number)
docker buildx imagetools create \
-t ghcr.io/${{ env.IMAGE_NAME }}:pr-ci-full \
ghcr.io/${{ env.IMAGE_NAME }}:${VERSION}-full-linux-amd64 \
ghcr.io/${{ env.IMAGE_NAME }}:${VERSION}-full-linux-arm64
- name: Create and push latest manifests - standard (GHCR)
if: github.event_name != 'pull_request' && needs.calculate-version.outputs.is_main_commit != 'true' && needs.build-standard.outputs.skipped != 'true'
run: |
VERSION=${{ needs.calculate-version.outputs.image_version }}
# GHCR - latest (traditional alias pointing to standard)
docker buildx imagetools create \
-t ghcr.io/${{ env.IMAGE_NAME }}:latest \
ghcr.io/${{ env.IMAGE_NAME }}:${VERSION}-standard-linux-amd64 \
ghcr.io/${{ env.IMAGE_NAME }}:${VERSION}-standard-linux-arm64
# GHCR - latest-standard
docker buildx imagetools create \
-t ghcr.io/${{ env.IMAGE_NAME }}:latest-standard \
ghcr.io/${{ env.IMAGE_NAME }}:${VERSION}-standard-linux-amd64 \
ghcr.io/${{ env.IMAGE_NAME }}:${VERSION}-standard-linux-arm64
- name: Create and push latest manifests - full (GHCR)
if: github.event_name != 'pull_request' && needs.calculate-version.outputs.is_main_commit != 'true'
run: |
VERSION=${{ needs.calculate-version.outputs.image_version }}
# GHCR - latest-full
docker buildx imagetools create \
-t ghcr.io/${{ env.IMAGE_NAME }}:latest-full \
ghcr.io/${{ env.IMAGE_NAME }}:${VERSION}-full-linux-amd64 \
ghcr.io/${{ env.IMAGE_NAME }}:${VERSION}-full-linux-arm64
- name: Create and push latest manifests - standard (DockerHub)
if: github.event_name != 'pull_request' && needs.calculate-version.outputs.is_main_commit != 'true' && needs.build-standard.outputs.skipped != 'true' && needs.calculate-version.outputs.skip_dockerhub != 'true' && steps.check_dockerhub.outputs.has_credentials == 'true'
run: |
VERSION=${{ needs.calculate-version.outputs.image_version }}
# DockerHub - latest (traditional alias pointing to standard)
docker buildx imagetools create \
-t ${{ secrets.DOCKERHUB_USERNAME }}/n.e.k.o:latest \
${{ secrets.DOCKERHUB_USERNAME }}/n.e.k.o:${VERSION}-standard-linux-amd64 \
${{ secrets.DOCKERHUB_USERNAME }}/n.e.k.o:${VERSION}-standard-linux-arm64
# DockerHub - latest-standard
docker buildx imagetools create \
-t ${{ secrets.DOCKERHUB_USERNAME }}/n.e.k.o:latest-standard \
${{ secrets.DOCKERHUB_USERNAME }}/n.e.k.o:${VERSION}-standard-linux-amd64 \
${{ secrets.DOCKERHUB_USERNAME }}/n.e.k.o:${VERSION}-standard-linux-arm64
- name: Create and push latest manifests - full (DockerHub)
if: github.event_name != 'pull_request' && needs.calculate-version.outputs.is_main_commit != 'true' && needs.calculate-version.outputs.skip_dockerhub != 'true' && steps.check_dockerhub.outputs.has_credentials == 'true'
run: |
VERSION=${{ needs.calculate-version.outputs.image_version }}
# DockerHub - latest-full
docker buildx imagetools create \
-t ${{ secrets.DOCKERHUB_USERNAME }}/n.e.k.o:latest-full \
${{ secrets.DOCKERHUB_USERNAME }}/n.e.k.o:${VERSION}-full-linux-amd64 \
${{ secrets.DOCKERHUB_USERNAME }}/n.e.k.o:${VERSION}-full-linux-arm64