-
Notifications
You must be signed in to change notification settings - Fork 9
233 lines (195 loc) · 7.02 KB
/
virt-minion-containers.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
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
name: "Virt Minion 🐳 Container"
on:
workflow_dispatch:
schedule:
- cron: "0 17 * * *"
push:
branches:
- '*'
paths:
- containers.yml
- '.github/workflows/virt-minion-containers.yml'
- 'custom/virt-minion/**'
pull_request:
paths:
- containers.yml
- '.github/workflows/virt-minion-containers.yml'
- 'custom/virt-minion/**'
env:
COLUMNS: 190
PATH_IN_REPO: custom/virt-minion
concurrency:
# New builds always cancel previous, still running, builds
group: custom/virt-minion-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
matrix-generator:
name: Generate Matrix
runs-on: ubuntu-22.04
outputs:
tags: ${{ steps.set-matrix.outputs.tags }}
name: ${{ steps.set-matrix.outputs.name }}
dockerinfo: ${{ steps.set-matrix.outputs.dockerinfo }}
steps:
- name: "Throttle Builds"
run: |
t="$(shuf -i 5-30 -n 1)"; echo "Sleeping $t seconds"; sleep "$t"
- name: "Fetching Repository Contents"
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Requirements
run: |
python -m pip install -r requirements.txt
- name: Show tools version
run: |
tools --debug --version
- name: "Generate Matrix Data"
id: set-matrix
run: |
tools ci matrix ${{ env.PATH_IN_REPO }}
build:
runs-on: ubuntu-22.04
needs: matrix-generator
name: "Build ${{ matrix.dockerinfo.name }}:${{ matrix.dockerinfo.tag }}${{ matrix.dockerinfo.platform && format(' ({0})', matrix.dockerinfo.platform) || ''}}"
timeout-minutes: 600
strategy:
fail-fast: false
max-parallel: 10
matrix:
dockerinfo: ${{ fromJson(needs.matrix-generator.outputs.dockerinfo) }}
permissions:
actions: read
checks: write
issues: read
packages: write
pull-requests: read
repository-projects: read
statuses: read
steps:
- name: "Fetching Repository Contents"
uses: actions/checkout@v4
- name: "Throttle concurrent pushes"
run: |
t="$(shuf -i 5-30 -n 1)"; echo "Sleeping $t seconds"; sleep "$t"
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}/${{ matrix.dockerinfo.name }}
tags: |
type=raw,value=${{ matrix.dockerinfo.tag }}
flavor: |
latest=false
- name: "Docker QEMU"
uses: docker/setup-qemu-action@v3
- name: "Docker BuildX"
id: buildx
uses: docker/setup-buildx-action@v3
- name: Inspect builder
run: |
echo "Name: ${{ steps.buildx.outputs.name }}"
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
echo "Status: ${{ steps.buildx.outputs.status }}"
echo "Flags: ${{ steps.buildx.outputs.flags }}"
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
- name: "Log into GitHub Container Registry"
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: "Build & Publish"
uses: docker/build-push-action@v5
id: build
with:
file: ${{ matrix.dockerinfo.file }}
context: ${{ env.PATH_IN_REPO }}
platforms: ${{ matrix.dockerinfo.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=ghcr.io/${{ github.repository }}/${{ matrix.dockerinfo.name }},push-by-digest=true,name-canonical=true,push=${{
github.repository == 'saltstack/salt-ci-containers' && contains(fromJSON('["push", "schedule", "workflow_dispatch"]'), github.event_name) }}
- name: Export digest
if: ${{ github.repository == 'saltstack/salt-ci-containers' && contains(fromJSON('["push", "schedule", "workflow_dispatch"]'), github.event_name) }}
run: |
mkdir -p /tmp/digests
touch "/tmp/digests/$(echo ${{ steps.build.outputs.digest }} | cut -d ':' -f 2)"
ls -lah /tmp/digests
- name: Upload digest
if: ${{ github.repository == 'saltstack/salt-ci-containers' && contains(fromJSON('["push", "schedule", "workflow_dispatch"]'), github.event_name) }}
uses: actions/upload-artifact@v4
with:
name: digests-${{ matrix.dockerinfo.name }}-${{ matrix.dockerinfo.tag }}-${{ matrix.dockerinfo.platform_slug }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
merge:
runs-on: ubuntu-22.04
name: "Merge ${{ needs.matrix-generator.outputs.name }}:${{ matrix.tag }}"
if: ${{ github.repository == 'saltstack/salt-ci-containers' && contains(fromJSON('["push", "schedule", "workflow_dispatch"]'), github.event_name) }}
strategy:
fail-fast: false
max-parallel: 10
matrix:
tag: ${{ fromJson(needs.matrix-generator.outputs.tags) }}
needs:
- matrix-generator
- build
permissions:
actions: read
checks: write
issues: read
packages: write
pull-requests: read
repository-projects: read
statuses: read
steps:
- name: "Fetching Repository Contents"
uses: actions/checkout@v4
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Requirements
run: |
python -m pip install -r requirements.txt
- name: Show tools version
run: |
tools --debug --version
- name: Download digests
uses: actions/download-artifact@v4
with:
pattern: digests-${{ needs.matrix-generator.outputs.name }}-${{ matrix.tag }}-*
merge-multiple: true
path: /tmp/digests
- name: Show digests
run: |
tree -a /tmp/digests
cat /tmp/digests/*
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository }}/${{ needs.matrix-generator.outputs.name }}
tags: |
type=raw,value=${{ matrix.tag }}
flavor: |
latest=false
- name: "Log into GitHub Container Registry"
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create manifest list and push
run: |
tools ci create-manifest-list-and-push ghcr.io/${{ github.repository }}/${{ needs.matrix-generator.outputs.name }} /tmp/digests
- name: Inspect image
run: |
docker buildx imagetools inspect ghcr.io/${{ github.repository }}/${{ needs.matrix-generator.outputs.name }}:${{ steps.meta.outputs.version }}