-
Notifications
You must be signed in to change notification settings - Fork 17
154 lines (134 loc) · 5.15 KB
/
Copy pathci-docker.yml
File metadata and controls
154 lines (134 loc) · 5.15 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
name: ci - linux docker build
on:
workflow_call:
env:
DOCKERHUB_REPO: ${{ github.repository }}
GHCR_REPO: ghcr.io/${{ github.repository }}
SET_IMAGE_TAG: latest
GH_TOKEN: ${{ github.token }}
jobs:
build:
runs-on: ubuntu-24.04-arm
outputs:
latest_tag: ${{ steps.gh_latest_tag.outputs.latest_tag }}
strategy:
fail-fast: false
matrix:
arch: [amd64, arm32v6, arm32v7, arm64v8, i386, ppc64le, riscv64, s390x]
include:
- arch: amd64
platform: linux/amd64
- arch: arm32v6
platform: linux/arm/v6
- arch: arm32v7
platform: linux/arm/v7
- arch: arm64v8
platform: linux/arm64
- arch: i386
platform: linux/386
- arch: ppc64le
platform: linux/ppc64le
- arch: riscv64
platform: linux/riscv64
- arch: s390x
platform: linux/s390x
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Fetch latest GitHub tag
id: gh_latest_tag
run: |
latest_tag="$(gh release list --json tagName -L 1 -q '.[0].tagName')"
printf '%s\n' "latest_tag=${latest_tag//+/-dev}" >> "$GITHUB_ENV"
printf '%s\n' "latest_tag=${latest_tag//+/-dev}" >> "$GITHUB_OUTPUT"
- name: Prepare
run: |
platform=${{ matrix.platform }}
printf '%s\n' "matrix_platform_hypens=${platform//\//-}" >> $GITHUB_ENV
- name: Docker meta
id: meta
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
with:
images: ${{ env.GHCR_REPO }}
- name: Login to GHCR
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ github.token }}
- name: Set up QEMU
uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4.3.0
with:
cache-binary: false
- name: Build and push by digest
id: build
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
with:
context: .
platforms: ${{ matrix.platform }}
provenance: false
push: true
tags: ${{ env.GHCR_REPO }}:${{ steps.meta.outputs.version }}
labels: ${{ steps.meta.outputs.labels }}
no-cache: true
build-args: |
ARCH=${{ matrix.arch }}
REPO=${{ github.repository }}
- name: Export digest
env:
digest: ${{ steps.build.outputs.digest }}
run: |
mkdir -p ${{ runner.temp }}/digests
digest="${digest}"
touch "${{ runner.temp }}/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: digests-${{ env.matrix_platform_hypens }}
path: ${{ runner.temp }}/digests/*
if-no-files-found: error
merge:
runs-on: ubuntu-24.04-arm
needs: build
env:
latest_tag: ${{ needs.build.outputs.latest_tag }}
steps:
- name: Download digests
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: ${{ runner.temp }}/digests
pattern: digests-*
merge-multiple: true
- name: Login to GHCR
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ github.token }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4.3.0
with:
cache-binary: false
- name: Docker meta
id: meta
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
with:
images: ${{ env.GHCR_REPO }}
- name: Create manifest list and push latest
working-directory: ${{ runner.temp }}/digests
run: |
ghcr_digests=$(for digest in *; do printf '%s@sha256:%s ' "${GHCR_REPO}" "${digest}"; done)
docker buildx imagetools create -t ${GHCR_REPO}:latest ${ghcr_digests}
- name: Create manifest list and push (version)
working-directory: ${{ runner.temp }}/digests
run: |
ghcr_digests=$(for digest in *; do printf '%s@sha256:%s ' "${GHCR_REPO}" "${digest}"; done)
docker buildx imagetools create -t ${GHCR_REPO}:${latest_tag} ${ghcr_digests}
- name: Inspect image
run: |
docker buildx imagetools inspect ${GHCR_REPO}:latest
docker buildx imagetools inspect ${GHCR_REPO}:${latest_tag}