-
Notifications
You must be signed in to change notification settings - Fork 36
186 lines (173 loc) · 6.72 KB
/
publish_docker_matrix_debian.yml
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
name: Docker Image Publish Matrix (Debian)
on:
workflow_dispatch:
workflow_call:
push:
branches:
- master
- develop
tags:
- tc_nightly*
- tc_v*.*.*
pull_request:
branches: [ "master", "develop" ]
# permissions are needed if pushing to ghcr.io
permissions:
packages: write
env:
REGISTRY_IMAGE: ghcr.io/toniebox-reverse-engineering/teddycloud
jobs:
build:
strategy:
fail-fast: false
matrix:
platform: [linux/amd64,linux/arm/v7,linux/arm64/v8,linux/i386,linux/ppc64le,linux/s390x]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta matrix
id: matrix_meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
type=schedule
type=schedule,pattern=nightly
type=schedule,pattern={{date 'YYYYMMDD'}}
type=schedule,pattern={{date 'YYYYMMDD-hhmmss' tz='Germany/Berlin'}}
type=ref,event=branch
type=ref,event=pr
type=sha
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/tc_v') }}
type=raw,value=nightly,enable=${{ startsWith(github.ref, 'refs/tags/tc_nightly') }}
type=raw,value=nightly-develop,enable=${{ github.ref == 'refs/heads/develop' }}
type=ref,event=tag
type=match,pattern=tc_v(\d+),group=1
type=match,pattern=tc_v(\d+.\d+),group=1
type=match,pattern=tc_v(\d+.\d+.\d+),group=1
type=match,pattern=tc_v(\d+.\d+.\d+-\S+),group=1
flavor: |
prefix=arch_,onlatest=true
suffix=_${{ matrix.platform }}_debian,onlatest=true
- name: Build & push digest docker ${{ matrix.platform }}
id: build
uses: docker/build-push-action@v5
with:
context: .
file: DockerfileDebian
platforms: ${{ matrix.platform }}
push: true
labels: ${{ steps.matrix_meta.outputs.labels }}
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Platform name strip for filename
id: platform_strip
run: |
platform=$(echo "${{ matrix.platform }}" | tr '/' '_')
echo "platform=$platform"
echo "platform=$platform" >> $GITHUB_OUTPUT
- name: Run docker image test
run: |
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker run -e DOCKER_TEST=1 --platform ${{ matrix.platform }} --name teddyCloud-test ${{ env.REGISTRY_IMAGE }}@${{ steps.build.outputs.digest }}
continue-on-error: ${{ matrix.platform == 'linux/s390x' || matrix.platform == 'linux/ppc64le' || matrix.platform == 'linux/arm/v7' }}
- name: Extract release zip
run: |
docker cp teddyCloud-test:/tmp/teddycloud.zip /tmp/teddycloud.${{ steps.platform_strip.outputs.platform }}.release.zip
docker rm teddyCloud-test
continue-on-error: ${{ matrix.platform == 'linux/s390x' }}
- name: Export digest
run: |
mkdir -p /tmp/digests/${{ github.sha }}
digest="${{ steps.build.outputs.digest }}"
commit_sha="${{ github.sha }}"
touch "/tmp/digests/${commit_sha}/${digest#sha256:}"
- name: Push docker tags ${{ matrix.platform }}
id: push_tags
uses: docker/build-push-action@v5
with:
context: .
file: DockerfileDebian
platforms: ${{ matrix.platform }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.matrix_meta.outputs.tags }}
labels: ${{ steps.matrix_meta.outputs.labels }}
- name: Upload digest
uses: actions/upload-artifact@v3
with:
name: digests
path: /tmp/digests/${{ github.sha }}/*
if-no-files-found: error
- name: Upload release file
uses: actions/upload-artifact@v3
with:
name: release-${{ steps.platform_strip.outputs.platform }}
path: /tmp/teddycloud.${{ steps.platform_strip.outputs.platform }}.release.zip
if-no-files-found: error
merge-images:
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Download digests
uses: actions/download-artifact@v3
with:
name: digests
path: /tmp/digests/${{ github.sha }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: teddycloud_meta # you'll use this in the next step
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: ${{ env.REGISTRY_IMAGE }}
# Docker tags based on the following events/attributes
tags: |
type=schedule
type=schedule,pattern=nightly
type=schedule,pattern={{date 'YYYYMMDD'}}
type=schedule,pattern={{date 'YYYYMMDD-hhmmss' tz='Germany/Berlin'}}
type=ref,event=branch
type=ref,event=pr
type=sha
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/tc_v') }}
type=raw,value=nightly,enable=${{ startsWith(github.ref, 'refs/tags/tc_nightly') }}
type=raw,value=nightly-develop,enable=${{ github.ref == 'refs/heads/develop' }}
type=ref,event=tag
type=match,pattern=tc_v(\d+),group=1
type=match,pattern=tc_v(\d+.\d+),group=1
type=match,pattern=tc_v(\d+.\d+.\d+),group=1
type=match,pattern=tc_v(\d+.\d+.\d+-\S+),group=1
flavor: |
suffix=_debian,onlatest=true
- name: Create manifest list and push
if: ${{ github.event_name != 'pull_request' }}
working-directory: /tmp/digests/${{ github.sha }}
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
- name: Inspect image
if: ${{ github.event_name != 'pull_request' }}
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.teddycloud_meta.outputs.version }}