-
Notifications
You must be signed in to change notification settings - Fork 0
471 lines (436 loc) Β· 18.9 KB
/
cid.yaml
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
name: "CID"
on:
workflow_dispatch:
inputs:
debug_enabled:
description: "Run the workflow with tmate.io debugging enabled"
required: true
type: boolean
default: false
run_build_images:
description: "Run build-images job"
required: false
type: boolean
default: false
run_execute_workflow:
description: "Run execute-workflow job"
required: false
type: boolean
default: false
pull_request:
types: [opened, labeled, reopened, synchronize]
paths-ignore:
- "testing/**"
- "**.md"
- "*"
- "!flake.nix"
- "!flake.lock"
push:
branches:
- "main"
- "beta"
paths-ignore:
- "testing/**"
- "**.md"
- "*"
- "!flake.nix"
- "!flake.lock"
defaults:
run:
shell: bash
permissions:
actions: write
contents: read
jobs:
scan:
name: gitguardian
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
with:
fetch-depth: 0 # fetch all history so multiple commits can be scanned
- name: GitGuardian scan
uses: GitGuardian/ggshield-action@e8eef84fc3419d2a7e7beb15ab96c95b3ce2da24 # ratchet:GitGuardian/[email protected]
env:
GITHUB_PUSH_BEFORE_SHA: ${{ github.event.before }}
GITHUB_PUSH_BASE_SHA: ${{ github.event.base }}
GITHUB_PULL_BASE_SHA: ${{ github.event.pull_request.base.sha }}
GITHUB_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
GITGUARDIAN_API_KEY: ${{ secrets.GITGUARDIAN_API_KEY }}
set-variables:
needs: scan
runs-on: ubuntu-latest
outputs:
debug: ${{ steps.set-variables.outputs.debug }}
skip_ci: ${{ steps.set-variables.outputs.skip_ci }}
skip_tests: ${{ steps.set-variables.outputs.skip_tests }}
checkout_ref: ${{ steps.set-variables.outputs.checkout_ref }}
steps:
- name: Set action variables
id: set-variables
run: |
DEBUG="false"
SKIP_CI="false"
SKIP_TESTS="false"
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
DEBUG="${{ inputs.debug_enabled }}"
fi
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
if ${{ contains(github.event.pull_request.labels.*.name, 'skip-ci') }}; then
SKIP_CI="true"
fi
if ${{ contains(github.event.pull_request.labels.*.name, 'skip-tests') }}; then
SKIP_TESTS="true"
fi
if ${{ contains(github.event.pull_request.labels.*.name, 'actions-debug') }}; then
DEBUG="true"
fi
CHECKOUT_REF="${{ github.event.pull_request.head.ref }}"
else
CHECKOUT_REF="${{ github.ref }}"
fi
echo "DEBUG=$DEBUG"
echo "SKIP_CI=$SKIP_CI"
echo "SKIP_TESTS=$SKIP_TESTS"
echo "DEBUG=$DEBUG" >> $GITHUB_OUTPUT
echo "SKIP_CI=$SKIP_CI" >> $GITHUB_OUTPUT
echo "SKIP_TESTS=$SKIP_TESTS" >> $GITHUB_OUTPUT
echo "CHECKOUT_REF=$CHECKOUT_REF" >> $GITHUB_OUTPUT
nixci:
needs: set-variables
runs-on: ubuntu-latest
concurrency:
group: nixci-${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.ref }}
cancel-in-progress: true
steps:
- name: Install dependencies
shell: bash
run: |
sudo apt-get update
sudo apt-get install -yq zstd
sudo apt-get clean
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@75ffa7fc743135e1db864b699d78402ccc8ed988 # ratchet:DeterminateSystems/nix-installer-action@main
with:
extra-conf: 'system-features = nixos-test benchmark big-parallel kvm'
# - name: Run the Magic Nix Cache
# uses: DeterminateSystems/magic-nix-cache-action@main
- uses: cachix/cachix-action@ad2ddac53f961de1989924296a1f236fcfbaa4fc # v15
with:
name: "${{ vars.CACHIX_CACHE_NAME }}"
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
extraPullNames: srid
- name: Setup tmate debug session
uses: mxschmitt/action-tmate@a283f9441d2d96eb62436dc46d7014f5d357ac22 # ratchet:mxschmitt/action-tmate@v3
if: ${{ inputs.debug_enabled }}
- name: Build
run: |
nix run github:srid/nixci -- build
build-nix-images:
runs-on: ubuntu-latest
needs: [set-variables]
if: ${{ needs.set-variables.outputs.skip_ci != 'true' && ( contains(github.event.pull_request.labels.*.name, 'build-images') || contains(github.event.pull_request.labels.*.name, 'execute-workflow') || (github.event_name == 'workflow_dispatch' && inputs.run_build_images) || (github.event_name == 'workflow_dispatch' && inputs.run_execute_workflow) ) }}
concurrency:
group: bni-${{ matrix.image }}-${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
packages: write
# environment:
# name: development
# url: "https://ghcr.io/cameronraysmith/nixpod"
strategy:
matrix:
image: [nixpod, codenix, ghanix, jupnix]
steps:
- name: Maximize build space
# uses: easimon/maximize-build-space@fc881a613ad2a34aca9c9624518214ebc21dfc0c # ratchet:easimon/maximize-build-space@v10
uses: cameronraysmith/maximize-build-space@fdf0c06b18d92be98aa64cb68ae4ea4c9bc4794d # ratchet:cameronraysmith/maximize-build-space@print-usage
with:
build-mount-path: /nix
build-mount-path-ownership: "root:root"
root-reserve-mb: 34816
swap-size-mb: 1024
remove-dotnet: "true"
remove-android: "true"
remove-codeql: "true"
remove-docker-images: "true"
- name: Install dependencies
shell: bash
run: |
sudo apt-get update
sudo apt-get install -yq zstd
sudo apt-get clean
- name: Setup build environment
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # ratchet:actions/checkout@v4
with:
ref: ${{ needs.set-variables.outputs.checkout_ref }}
- name: Build ${{ matrix.image }} image
uses: ./.github/actions/build-nix-image
with:
triggerEventName: ${{ github.event_name }}
imageName: "${{ matrix.image }}"
imageFQN: "ghcr.io/cameronraysmith/${{ matrix.image }}"
nixCommand: "nix run .#${{ matrix.image }}Manifest --impure --accept-flake-config --print-build-logs --show-trace"
releaseVersion: ""
cachixCacheName: ${{ vars.CACHIX_CACHE_NAME }}
cachixAuthToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
artifactRegistryPassword: ${{ secrets.ARTIFACT_REGISTRY_PASSWORD }}
# gcpProjectId: ${{ secrets.GCP_PROJECT_ID }}
# encodedGARCredentials: ${{ secrets.ENCODED_GAR_SA_CREDS }}
debnix:
runs-on: ubuntu-latest
needs: set-variables
if: ${{ needs.set-variables.outputs.skip_ci != 'true' && ( contains(github.event.pull_request.labels.*.name, 'build-images') || contains(github.event.pull_request.labels.*.name, 'execute-workflow') || (github.event_name == 'workflow_dispatch' && inputs.run_build_images) || (github.event_name == 'workflow_dispatch' && inputs.run_execute_workflow) ) }}
permissions:
contents: read
packages: write
concurrency:
group: debnix-${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.ref }}
cancel-in-progress: true
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
- name: Tag Build and Push Testing Container
uses: ./.github/actions/tag-build-push-container
with:
registry: ghcr.io
image-name: ${{ github.repository_owner }}/${{ github.job }}
containerfile-path: "containers/Containerfile.${{ github.job }}"
push-condition: ${{ github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'build-images') }}
github-token: ${{ secrets.GITHUB_TOKEN }}
debjupnix:
runs-on: ubuntu-latest
needs: set-variables
if: ${{ needs.set-variables.outputs.skip_ci != 'true' && ( contains(github.event.pull_request.labels.*.name, 'build-images') || contains(github.event.pull_request.labels.*.name, 'execute-workflow') || (github.event_name == 'workflow_dispatch' && inputs.run_build_images) || (github.event_name == 'workflow_dispatch' && inputs.run_execute_workflow) ) }}
permissions:
contents: read
packages: write
concurrency:
group: debjupnix-${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.ref }}
cancel-in-progress: true
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
- name: Tag Build and Push Testing Container
uses: ./.github/actions/tag-build-push-container
with:
registry: ghcr.io
image-name: ${{ github.repository_owner }}/${{ github.job }}
containerfile-path: "containers/Containerfile.debnix"
push-condition: ${{ github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'build-images') }}
github-token: ${{ secrets.GITHUB_TOKEN }}
build-args: |
USER=jovyan
UID=1000
GID=100
debnixpod:
runs-on: ubuntu-latest
needs: [scan, debnix]
permissions:
contents: read
packages: write
concurrency:
group: debnixpod-${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.ref }}
cancel-in-progress: true
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
- name: Tag Build and Push Testing Container
uses: ./.github/actions/tag-build-push-container
with:
registry: ghcr.io
image-name: ${{ github.repository_owner }}/${{ github.job }}
containerfile-path: "containers/Containerfile.${{ github.job }}"
push-condition: ${{ github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'build-images') }}
github-token: ${{ secrets.GITHUB_TOKEN }}
# build-deb-images:
# needs: [set-variables, scan]
# runs-on: ubuntu-latest
# permissions:
# contents: read
# packages: write
# concurrency:
# group: ${{ matrix.job }}-${{ github.workflow }}-${{ github.ref }}
# strategy:
# matrix:
# job: [debnix, debjupnix, debnixpod]
# steps:
# - uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
# - name: Tag Build and Push Testing Container
# uses: ./.github/actions/tag-build-push-container
# with:
# registry: ghcr.io
# image-name: ${{ github.repository_owner }}/${{ matrix.job }}
# containerfile-path: "containers/Containerfile.${{ matrix.job }}"
# push-condition: ${{ github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'build-images') }}
# github-token: ${{ secrets.GITHUB_TOKEN }}
# build-args: ${{ matrix.job == 'debjupnix' && 'USER=jovyan\nUID=1000\nGID=100' || '' }}
release:
runs-on: ubuntu-latest
needs: [nixci]
if: ${{ github.repository_owner == 'cameronraysmith' && github.event_name == 'push' }}
permissions:
contents: write
outputs:
version: ${{ steps.semantic-release.outputs.new_release_version }}
git-tag: ${{ steps.semantic-release.outputs.new_release_git_tag }}
released: ${{ steps.semantic-release.outputs.new_release_published }}
git-head: ${{ steps.semantic-release.outputs.new_release_git_head }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
fetch-depth: '0'
- name: Get semantic-release version
shell: sh
id: semantic-release-version
run: echo version=$(npm view @cihelper/semanticrelease-preset-generic dependencies.semantic-release) >> $GITHUB_OUTPUT
- name: Run semantic-release
id: semantic-release
uses: cycjimmy/semantic-release-action@cb425203a562475bca039ba4dbf90c7f9ac790f4 # v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
semantic_version: ${{ steps.semantic-release-version.outputs.version }}
extra_plugins: "@cihelper/semanticrelease-preset-generic@1"
extends: "@cihelper/semanticrelease-preset-generic"
# publish:
# needs: [release]
# runs-on: "ubuntu-latest"
# if: ${{ needs.release.outputs.released == 'true' }}
# concurrency:
# group: publish-${{ github.workflow }}-${{ github.ref }}-${{ github.sha }}
# cancel-in-progress: true
# permissions:
# id-token: "write"
# contents: "read"
# steps:
# - uses: "actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29" # v4
# with:
# ref: ${{ needs.release.outputs.git-tag }}
# - uses: "DeterminateSystems/nix-installer-action@75ffa7fc743135e1db864b699d78402ccc8ed988" # ratchet:DeterminateSystems/nix-installer-action@main
# - uses: "DeterminateSystems/flakehub-push@114496f7d11f17ceb7d1466a8aaeaef496b1041f" # ratchet:DeterminateSystems/flakehub-push@main
# with:
# visibility: "public"
# tag: ${{ needs.release.outputs.version }}
publish-nix-images:
runs-on: ubuntu-latest
needs: [release]
if: ${{ needs.release.outputs.released == 'true' }}
concurrency:
group: pni-${{ matrix.image }}-${{ github.workflow }}-${{ github.ref }}-${{ github.sha }}
cancel-in-progress: true
permissions:
contents: read
packages: write
# environment:
# name: development
# url: "https://ghcr.io/cameronraysmith/nixpod"
strategy:
matrix:
image: [nixpod, codenix, ghanix, jupnix]
steps:
- name: Maximize build space
# uses: easimon/maximize-build-space@fc881a613ad2a34aca9c9624518214ebc21dfc0c # ratchet:easimon/maximize-build-space@v10
uses: cameronraysmith/maximize-build-space@fdf0c06b18d92be98aa64cb68ae4ea4c9bc4794d # ratchet:cameronraysmith/maximize-build-space@print-usage
with:
build-mount-path: /nix
build-mount-path-ownership: "root:root"
root-reserve-mb: 34816
swap-size-mb: 1024
remove-dotnet: "true"
remove-android: "true"
remove-codeql: "true"
remove-docker-images: "true"
- name: Setup build environment
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # ratchet:actions/checkout@v4
with:
ref: ${{ needs.release.outputs.git-tag }}
- name: Install dependencies
shell: bash
run: |
sudo apt-get update
sudo apt-get install -yq zstd
sudo apt-get clean
- name: Build ${{ matrix.image }} image
uses: ./.github/actions/build-nix-image
with:
triggerEventName: ${{ github.event_name }}
imageName: "${{ matrix.image }}"
imageFQN: "ghcr.io/cameronraysmith/${{ matrix.image }}"
nixCommand: "nix run .#${{ matrix.image }}Manifest --impure --accept-flake-config --print-build-logs --show-trace"
releaseVersion: ${{ needs.release.outputs.version }}
cachixCacheName: ${{ vars.CACHIX_CACHE_NAME }}
cachixAuthToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
artifactRegistryPassword: ${{ secrets.ARTIFACT_REGISTRY_PASSWORD }}
# gcpProjectId: ${{ secrets.GCP_PROJECT_ID }}
# encodedGARCredentials: ${{ secrets.ENCODED_GAR_SA_CREDS }}
publish-debnix:
runs-on: ubuntu-latest
needs: [release]
if: ${{ needs.release.outputs.released == 'true' }}
permissions:
contents: read
packages: write
concurrency:
group: publish-debnix-${{ github.workflow }}-${{ github.ref }}-${{ github.sha }}
cancel-in-progress: true
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
with:
ref: ${{ needs.release.outputs.git-tag }}
- name: Tag Build and Push Testing Container
uses: ./.github/actions/tag-build-push-container
with:
registry: ghcr.io
image-name: ${{ github.repository_owner }}/debnix
containerfile-path: "containers/Containerfile.debnix"
push-condition: ${{ github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'build-images') }}
github-token: ${{ secrets.GITHUB_TOKEN }}
publish-debjupnix:
runs-on: ubuntu-latest
needs: [release]
if: ${{ needs.release.outputs.released == 'true' }}
permissions:
contents: read
packages: write
concurrency:
group: publish-debjupnix-${{ github.workflow }}-${{ github.ref }}-${{ github.sha }}
cancel-in-progress: true
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
with:
ref: ${{ needs.release.outputs.git-tag }}
- name: Tag Build and Push Testing Container
uses: ./.github/actions/tag-build-push-container
with:
registry: ghcr.io
image-name: ${{ github.repository_owner }}/debjupnix
containerfile-path: "containers/Containerfile.debnix"
push-condition: ${{ github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'build-images') }}
github-token: ${{ secrets.GITHUB_TOKEN }}
build-args: |
USER=jovyan
UID=1000
GID=100
publish-debnixpod:
runs-on: ubuntu-latest
needs: [release,publish-debnix]
if: ${{ needs.release.outputs.released == 'true' }}
permissions:
contents: read
packages: write
concurrency:
group: publish-debnixpod-${{ github.workflow }}-${{ github.ref }}-${{ github.sha }}
cancel-in-progress: true
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
with:
ref: ${{ needs.release.outputs.git-tag }}
- name: Tag Build and Push Testing Container
uses: ./.github/actions/tag-build-push-container
with:
registry: ghcr.io
image-name: ${{ github.repository_owner }}/debnixpod
containerfile-path: "containers/Containerfile.debnixpod"
push-condition: ${{ github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'build-images') }}
github-token: ${{ secrets.GITHUB_TOKEN }}