-
Notifications
You must be signed in to change notification settings - Fork 1
243 lines (220 loc) · 8.07 KB
/
build.yml
File metadata and controls
243 lines (220 loc) · 8.07 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
name: Build and Publish
on:
push:
branches:
- main
- master
schedule:
# Rebuild every 15 days even sin cambios para mantener imágenes frescas
- cron: "0 3 */15 * *"
workflow_dispatch:
jobs:
build-desktop:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
outputs:
run_build: ${{ steps.changes.outputs.run_build }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Detect changes for desktop
id: changes
run: |
if [ "${GITHUB_EVENT_NAME:-}" = "schedule" ]; then
echo "run_build=true" >> "$GITHUB_OUTPUT"
echo "Scheduled run: forcing desktop build."
exit 0
fi
BASE_REF="${{ github.event.before }}"
if [ -z "$BASE_REF" ] || ! git cat-file -e "$BASE_REF^{commit}" 2>/dev/null; then
BASE_REF="HEAD^"
fi
if git diff --quiet "$BASE_REF" HEAD -- Docker-Images/Desktop; then
echo "run_build=false" >> "$GITHUB_OUTPUT"
echo "No changes in Docker-Images/Desktop, skipping build."
else
echo "run_build=true" >> "$GITHUB_OUTPUT"
echo "Changes detected in Docker-Images/Desktop, building image."
fi
- name: Log in to GHCR
if: steps.changes.outputs.run_build == 'true'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
if: steps.changes.outputs.run_build == 'true'
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/coder-mks-desktop
tags: |
type=raw,value=latest
type=sha
- name: Set up Docker Buildx
if: steps.changes.outputs.run_build == 'true'
uses: docker/setup-buildx-action@v3
- name: Build and push
if: steps.changes.outputs.run_build == 'true'
uses: docker/build-push-action@v5
with:
context: Docker-Images/Desktop
push: true
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=coder-mks-desktop
cache-to: type=gha,mode=max,scope=coder-mks-desktop
build-args: |
BUILDKIT_STEP_TIMEOUT=1800
sbom: false
build-desktop-kde:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
outputs:
run_build: ${{ steps.changes.outputs.run_build }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Detect changes for desktop-kde
id: changes
run: |
if [ "${GITHUB_EVENT_NAME:-}" = "schedule" ]; then
echo "run_build=true" >> "$GITHUB_OUTPUT"
echo "Scheduled run: forcing desktop-kde build."
exit 0
fi
BASE_REF="${{ github.event.before }}"
if [ -z "$BASE_REF" ] || ! git cat-file -e "$BASE_REF^{commit}" 2>/dev/null; then
BASE_REF="HEAD^"
fi
if git diff --quiet "$BASE_REF" HEAD -- Docker-Images/Desktop-KDE; then
echo "run_build=false" >> "$GITHUB_OUTPUT"
echo "No changes in Docker-Images/Desktop-KDE, skipping build."
else
echo "run_build=true" >> "$GITHUB_OUTPUT"
echo "Changes detected in Docker-Images/Desktop-KDE, building image."
fi
- name: Log in to GHCR
if: steps.changes.outputs.run_build == 'true'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
if: steps.changes.outputs.run_build == 'true'
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/coder-mks-desktop-kde
tags: |
type=raw,value=latest
type=sha
- name: Set up Docker Buildx
if: steps.changes.outputs.run_build == 'true'
uses: docker/setup-buildx-action@v3
- name: Build and push
if: steps.changes.outputs.run_build == 'true'
uses: docker/build-push-action@v5
with:
context: Docker-Images/Desktop-KDE
push: true
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=coder-mks-desktop-kde
cache-to: type=gha,mode=max,scope=coder-mks-desktop-kde
build-args: |
BUILDKIT_STEP_TIMEOUT=1800
sbom: false
build:
needs: [build-desktop, build-desktop-kde]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
include:
- image_name: coder-mks-developer
context: Docker-Images/Developer
base_dep: desktop
- image_name: coder-mks-design
context: Docker-Images/Designer
base_dep: desktop-kde
- image_name: coder-mks-developer-android
context: Docker-Images/DeveloperAndroid
base_dep: desktop-kde
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Detect changes for image
id: changes
run: |
if [ "${GITHUB_EVENT_NAME:-}" = "schedule" ]; then
echo "run_build=true" >> "$GITHUB_OUTPUT"
echo "Scheduled run: forcing build for ${{ matrix.image_name }}."
exit 0
fi
# If a base image rebuilt, force dependent images to rebuild
if [ "${{ matrix.base_dep }}" = "desktop" ] && [ "${{ needs.build-desktop.outputs.run_build }}" = "true" ]; then
echo "run_build=true" >> "$GITHUB_OUTPUT"
echo "Desktop rebuilt; forcing build for ${{ matrix.image_name }}."
exit 0
fi
if [ "${{ matrix.base_dep }}" = "desktop-kde" ] && [ "${{ needs.build-desktop-kde.outputs.run_build }}" = "true" ]; then
echo "run_build=true" >> "$GITHUB_OUTPUT"
echo "Desktop-KDE rebuilt; forcing build for ${{ matrix.image_name }}."
exit 0
fi
BASE_REF="${{ github.event.before }}"
if [ -z "$BASE_REF" ] || ! git cat-file -e "$BASE_REF^{commit}" 2>/dev/null; then
BASE_REF="HEAD^"
fi
if git diff --quiet "$BASE_REF" HEAD -- "${{ matrix.context }}"; then
echo "run_build=false" >> "$GITHUB_OUTPUT"
echo "No changes in ${{ matrix.context }}, skipping build."
else
echo "run_build=true" >> "$GITHUB_OUTPUT"
echo "Changes detected in ${{ matrix.context }}, building image."
fi
- name: Log in to GHCR
uses: docker/login-action@v3
if: steps.changes.outputs.run_build == 'true'
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
if: steps.changes.outputs.run_build == 'true'
with:
images: ghcr.io/${{ github.repository_owner }}/${{ matrix.image_name }}
tags: |
type=raw,value=latest
type=sha
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
if: steps.changes.outputs.run_build == 'true'
- name: Build and push
uses: docker/build-push-action@v5
if: steps.changes.outputs.run_build == 'true'
with:
context: ${{ matrix.context }}
push: true
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=${{ matrix.image_name }}
cache-to: type=gha,mode=max,scope=${{ matrix.image_name }}
build-args: |
BUILDKIT_STEP_TIMEOUT=1800
sbom: false