-
Notifications
You must be signed in to change notification settings - Fork 2
654 lines (583 loc) · 30.2 KB
/
deploy_docker.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
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
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
name: Build and Publish Docker Images
on:
# Run this workflow every time a pull request is opened or updated with the development branch as the base
# and there is a change to the dockerfiles or any of the package build scripts.
pull_request:
branches: ["development"]
paths:
- ".devcontainer/Dockerfile_Jammy"
- ".devcontainer/Dockerfile_JetPack"
- ".github/workflows/deploy_docker.yml"
- "tools/package-builders/geolib/geolib-arm64-pkg.sh"
- "tools/package-builders/geolib/geolib-amd64-pkg.sh"
- "tools/package-builders/libdatachannel/libdatachannel-arm64-pkg.sh"
- "tools/package-builders/libdatachannel/libdatachannel-amd64-pkg.sh"
- "tools/package-builders/ffmpeg/ffmpeg-arm64-pkg.sh"
- "tools/package-builders/ffmpeg/ffmpeg-amd64-pkg.sh"
- "tools/package-builders/gtest/gtest-arm64-pkg.sh"
- "tools/package-builders/gtest/gtest-amd64-pkg.sh"
- "tools/package-builders/opencv/opencv-arm64-pkg.sh"
- "tools/package-builders/opencv/opencv-amd64-pkg.sh"
- "tools/package-builders/pytorch/pytorch-arm64-pkg.sh"
- "tools/package-builders/pytorch/pytorch-amd64-pkg.sh"
- "tools/package-builders/abseil/abseil-arm64-pkg.sh"
- "tools/package-builders/abseil/abseil-amd64-pkg.sh"
- "tools/package-builders/tensorflow/tensorflow-arm64-pkg.sh"
- "tools/package-builders/tensorflow/tensorflow-amd64-pkg.sh"
- "tools/package-builders/quill/quill-arm64-pkg.sh"
- "tools/package-builders/quill/quill-amd64-pkg.sh"
# Or, run this workflow every time a push/merge is made to the development branch and there is a change to
# the dockerfiles or any of the package build scripts.
push:
branches: ["development"]
paths:
- ".devcontainer/Dockerfile_Jammy"
- ".devcontainer/Dockerfile_JetPack"
- ".github/workflows/deploy_docker.yml"
- "tools/package-builders/geolib/geolib-arm64-pkg.sh"
- "tools/package-builders/geolib/geolib-amd64-pkg.sh"
- "tools/package-builders/libdatachannel/libdatachannel-arm64-pkg.sh"
- "tools/package-builders/libdatachannel/libdatachannel-amd64-pkg.sh"
- "tools/package-builders/ffmpeg/ffmpeg-arm64-pkg.sh"
- "tools/package-builders/ffmpeg/ffmpeg-amd64-pkg.sh"
- "tools/package-builders/gtest/gtest-arm64-pkg.sh"
- "tools/package-builders/gtest/gtest-amd64-pkg.sh"
- "tools/package-builders/opencv/opencv-arm64-pkg.sh"
- "tools/package-builders/opencv/opencv-amd64-pkg.sh"
- "tools/package-builders/pytorch/pytorch-arm64-pkg.sh"
- "tools/package-builders/pytorch/pytorch-amd64-pkg.sh"
- "tools/package-builders/abseil/abseil-arm64-pkg.sh"
- "tools/package-builders/abseil/abseil-amd64-pkg.sh"
- "tools/package-builders/tensorflow/tensorflow-arm64-pkg.sh"
- "tools/package-builders/tensorflow/tensorflow-amd64-pkg.sh"
- "tools/package-builders/quill/quill-arm64-pkg.sh"
- "tools/package-builders/quill/quill-amd64-pkg.sh"
# Or, run this manually from the Actions tab in GitHub. This will run the workflow on the development branch.
workflow_dispatch:
# This workflow has concurrency protection enabled. This means that if the workflow is already running, it will
# wait until the previous run is complete before starting a new run. This is to prevent multiple runs from
# happening at the same time and causing conflicts. If there are more than (2) runs waiting in the queue, the
# workflow will be cancelled. This is to prevent the queue from getting too long and causing delays in the
# workflow. It will not cancel a run that is already in progress.
concurrency:
group: "docker"
cancel-in-progress: false
# This workflow is split into multiple jobs. Each job is run on a different runner. This allows multiple jobs to
# run at the same time. The jobs are run in parallel unless they have a dependency on another job. If a job has
# a dependency on another job, it will wait until the other job is complete before starting.
jobs:
# This job is used to get the current date and time. This is used to tag the docker images. The date and time
# job is run first so that all of the docker images are tagged with the same date and time. And is a dependency
# for the other jobs.
time-and-date:
runs-on: [ubuntu-latest]
timeout-minutes: 360
# This outputs the current date and time to the GitHub output. This is used to tag the docker images.
outputs:
date: ${{ steps.date.outputs.date }}
steps:
# This step is used to get the current date and time. And outputs it to the GitHub output.
- name: Get Current Date and Time
id: date
run: echo "date=$(date +'%Y-%m-%d-%H-%M-%S')" >> $GITHUB_OUTPUT
# This job is used to check if any of the packages for AMD64 need to be rebuilt. If any of the package build
# scripts have been updated, then the packages need to be rebuilt in the next job. This job is run on a self-
# hosted runner because there is not an NVIDIA GPU available on the GitHub runners. It outputs a variable for
# each package that is set to true if the package needs to be rebuilt. This job is only run on pull requests.
check-amd64-packages:
needs: [time-and-date]
runs-on: [self-hosted, linux, X64]
timeout-minutes: 1440
if: github.event_name == 'pull_request'
# This outputs a variable for each package that is set to true if the package needs to be rebuilt. This is
# used to determine if the docker images need to be rebuilt.
outputs:
geolib-amd64: ${{ steps.changes.outputs.geolib-amd64 }}
libdatachannel-amd64: ${{ steps.changes.outputs.libdatachannel-amd64 }}
ffmpeg-amd64: ${{ steps.changes.outputs.ffmpeg-amd64 }}
gtest-amd64: ${{ steps.changes.outputs.gtest-amd64 }}
opencv-amd64: ${{ steps.changes.outputs.opencv-amd64 }}
pytorch-amd64: ${{ steps.changes.outputs.pytorch-amd64 }}
abseil-amd64: ${{ steps.changes.outputs.abseil-amd64 }}
tensorflow-amd64: ${{ steps.changes.outputs.tensorflow-amd64 }}
quill-amd64: ${{ steps.changes.outputs.quill-amd64 }}
steps:
- name: Setup Action Environment
if: always()
run: |
cd /opt
if [ ! -d "Autonomy_Software" ]; then git clone --recurse-submodules -j8 https://github.com/MissouriMRDT/Autonomy_Software.git; fi
# This step is used to checkout the repository. It is needed so that the package build scripts can be
# checked for changes.
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
# This step is used to check if any of the package build scripts have been updated. If any of the package
# build scripts have been updated, then the packages need to be rebuilt in the next job. This step outputs
# a variable for each package that is set to true if the package needs to be rebuilt.
- name: Check for Updated Files
id: changes
uses: dorny/paths-filter@v3
with:
filters: |
geolib-amd64:
- 'tools/package-builders/geolib/geolib-amd64-pkg.sh'
libdatachannel-amd64:
- 'tools/package-builders/libdatachannel/libdatachannel-amd64-pkg.sh'
ffmpeg-amd64:
- 'tools/package-builders/ffmpeg/ffmpeg-amd64-pkg.sh'
gtest-amd64:
- 'tools/package-builders/gtest/gtest-amd64-pkg.sh'
opencv-amd64:
- 'tools/package-builders/opencv/opencv-amd64-pkg.sh'
pytorch-amd64:
- 'tools/package-builders/pytorch/pytorch-amd64-pkg.sh'
abseil-amd64:
- 'tools/package-builders/abseil/abseil-amd64-pkg.sh'
tensorflow-amd64:
- 'tools/package-builders/tensorflow/tensorflow-amd64-pkg.sh'
quill-amd64:
- 'tools/package-builders/quill/quill-amd64-pkg.sh'
- name: Cleanup Action Environment
if: always()
run: |
cd /opt
rm -rf /opt/Autonomy_Software
# This job is to rebuild the updated AMD64 packages and push them to the package repository. It is run on a
# self-hosted runner because there is not an NVIDIA GPU available on the GitHub runners. It gets the list of
# packages that need to be rebuilt from the previous job. It outputs a variable for each package that is set
# to true if the package was rebuilt. This runs in a development matrix so that each package is rebuilt in a
# separate job. This allows multiple packages to be rebuilt at the same time. This job is only run on pull
# requests.
build-updated-amd64-packages:
needs: [time-and-date, check-amd64-packages]
runs-on: [self-hosted, linux, X64]
timeout-minutes: 1440
environment:
name: docker-packages
url: https://github.com/MissouriMRDT/Autonomy_Packages
if: github.event_name == 'pull_request'
# This strategy is used to run the job for each package that needs to be rebuilt. This allows multiple
# packages to be rebuilt at the same time. The job will fail if any of the packages fail to build. But the
# other packages will continue to build. This is so that the packages can be rebuilt in parallel, if
# there are enough action runners in service.
strategy:
fail-fast: false
matrix:
package:
- geolib
- libdatachannel
- ffmpeg
- gtest
- opencv
- pytorch
- abseil
- tensorflow
- quill
steps:
- name: Setup Action Environment
if: always()
run: |
cd /opt
if [ ! -d "Autonomy_Software" ]; then git clone --recurse-submodules -j8 https://github.com/MissouriMRDT/Autonomy_Software.git; fi
# This step is used to checkout the repository. It is needed so that the package build scripts can be
# checked for changes.
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
# This step is used to rebuild the updated package. It gets the list of packages that need to be rebuilt
# from the previous job. It runs the package build script for the package that is being built.
- name: Rebuild ${{ matrix.package }} Package
id: rebuild_pkg
if: needs.check-amd64-packages.outputs.${{ matrix.package }}-amd64 == 'true'
run: |
cd tools/package-builders/${{ matrix.package }}
chmod +x ${{ matrix.package }}-amd64-pkg.sh
./${{ matrix.package }}-amd64-pkg.sh
# This step is used to push the updated package to the package repository. It clones the package
# repository using SSH. It copies the new package into the repository. And then, commits and pushes
# the changes.
- name: Push Packages
if: steps.rebuild_pkg.outputs.rebuilding_pkg == 'true'
run: |
# Find Debian Package
debfile=$(find /tmp/pkg/deb/ -name "*.deb" -type f -print -quit)
# Set up Git configuration
git config --global user.email "[email protected]"
git config --global user.name "MRDT-Software"
# Set up SSH key
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan github.com >> ~/.ssh/known_hosts
# Clone the destination repository using SSH
git clone [email protected]:MissouriMRDT/Autonomy_Packages.git
cd Autonomy_Packages
# Copy the new AMD64 packages into the repository
mkdir -p ${{ matrix.package }}/amd64/
cp -r /tmp/pkg/deb/*amd64*.deb ${{ matrix.package }}/amd64/
# Set up Git LFS
git lfs install
# Commit and push changes
git lfs track '*.deb'
git add .gitattributes
git add .
git commit -m "Upgrade ${{ matrix.package }} Package for AMD64"
git push origin main
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
# This step is used to remove the package from the temporary directory. It gets the list of packages that
# need to be rebuilt from the previous job. It removes the package from the temporary directory. This is
# done so that the next package can be built without having to worry about the previous package causing
# conflicts.
- name: Remove ${{ matrix.package }} Package
if: steps.rebuild_pkg.outputs.rebuilding_pkg == 'true'
run: rm -rf /tmp/pkg/*
- name: Cleanup Action Environment
if: always()
run: |
cd /opt
rm -rf /opt/Autonomy_Software
# This job is used to check if any of the packages for ARM64 need to be rebuilt. If any of the package build
# scripts have been updated, then the packages need to be rebuilt in the next job. This job is run on a self-
# hosted runner because there is not an NVIDIA GPU available on the GitHub runners. It outputs a variable for
# each package that is set to true if the package needs to be rebuilt. This job is only run on pull requests.
check-arm64-packages:
needs: [time-and-date]
runs-on: [self-hosted, linux, ARM64]
timeout-minutes: 1440
if: github.event_name == 'pull_request'
# This outputs a variable for each package that is set to true if the package needs to be rebuilt. This is
# used to determine if the docker images need to be rebuilt.
outputs:
geolib-arm64: ${{ steps.changes.outputs.geolib-arm64 }}
libdatachannel-arm64: ${{ steps.changes.outputs.libdatachannel-arm64 }}
ffmpeg-arm64: ${{ steps.changes.outputs.ffmpeg-arm64 }}
gtest-arm64: ${{ steps.changes.outputs.gtest-arm64 }}
opencv-arm64: ${{ steps.changes.outputs.opencv-arm64 }}
pytorch-arm64: ${{ steps.changes.outputs.pytorch-arm64 }}
abseil-arm64: ${{ steps.changes.outputs.abseil-arm64 }}
tensorflow-arm64: ${{ steps.changes.outputs.tensorflow-arm64 }}
quill-arm64: ${{ steps.changes.outputs.quill-arm64 }}
steps:
- name: Setup Action Environment
if: always()
run: |
cd /opt
if [ ! -d "Autonomy_Software" ]; then git clone --recurse-submodules -j8 https://github.com/MissouriMRDT/Autonomy_Software.git; fi
# This step is used to checkout the repository. It is needed so that the package build scripts can be
# checked for changes.
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
# This step is used to check if any of the package build scripts have been updated. If any of the package
# build scripts have been updated, then the packages need to be rebuilt in the next job. This step outputs
# a variable for each package that is set to true if the package needs to be rebuilt.
- name: Check for Updated Files
id: changes
uses: dorny/paths-filter@v3
with:
filters: |
geolib-arm64:
- 'tools/package-builders/geolib/geolib-arm64-pkg.sh'
libdatachannel-arm64:
- 'tools/package-builders/libdatachannel/libdatachannel-arm64-pkg.sh'
ffmpeg-arm64:
- 'tools/package-builders/ffmpeg/ffmpeg-arm64-pkg.sh'
gtest-arm64:
- 'tools/package-builders/gtest/gtest-arm64-pkg.sh'
opencv-arm64:
- 'tools/package-builders/opencv/opencv-arm64-pkg.sh'
pytorch-arm64:
- 'tools/package-builders/pytorch/pytorch-arm64-pkg.sh'
abseil-arm64:
- 'tools/package-builders/abseil/abseil-arm64-pkg.sh'
tensorflow-arm64:
- 'tools/package-builders/tensorflow/tensorflow-arm64-pkg.sh'
quill-arm64:
- 'tools/package-builders/quill/quill-arm64-pkg.sh'
- name: Cleanup Action Environment
if: always()
run: |
cd /opt
rm -rf /opt/Autonomy_Software
# This job is to rebuild the updated ARM64 packages and push them to the package repository. It is run on a
# self-hosted runner because there is not an NVIDIA GPU available on the GitHub runners. It gets the list of
# packages that need to be rebuilt from the previous job. It outputs a variable for each package that is set
# to true if the package was rebuilt. This runs in a development matrix so that each package is rebuilt in a
# separate job. This allows multiple packages to be rebuilt at the same time. This job is only run on pull
# requests.
build-updated-arm64-packages:
needs: [time-and-date, check-arm64-packages]
runs-on: [self-hosted, linux, ARM64]
timeout-minutes: 1440
environment:
name: docker-packages
url: https://github.com/MissouriMRDT/Autonomy_Packages
if: github.event_name == 'pull_request'
# This strategy is used to run the job for each package that needs to be rebuilt. This allows multiple
# packages to be rebuilt at the same time. The job will fail if any of the packages fail to build. But the
# other packages will continue to build. This is so that the packages can be rebuilt in parallel.
strategy:
fail-fast: false
matrix:
package:
- geolib
- libdatachannel
- ffmpeg
- gtest
- opencv
- pytorch
- abseil
- tensorflow
- quill
steps:
- name: Setup Action Environment
if: always()
run: |
cd /opt
if [ ! -d "Autonomy_Software" ]; then git clone --recurse-submodules -j8 https://github.com/MissouriMRDT/Autonomy_Software.git; fi
# This step is used to checkout the repository. It is needed so that the package build scripts can be
# checked for changes.
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
# This step is used to rebuild the updated package. It gets the list of packages that need to be rebuilt
# from the previous job. It runs the package build script for the package that is being built.
- name: Rebuild ${{ matrix.package }} Package
id: rebuild_pkg
if: needs.check-arm64-packages.outputs.${{ matrix.package }}-arm64 == 'true'
run: |
cd tools/package-builders/${{ matrix.package }}
chmod +x ${{ matrix.package }}-arm64-pkg.sh
./${{ matrix.package }}-arm64-pkg.sh
# This step is used to push the updated package to the package repository. It clones the package
# repository using SSH. It copies the new package into the repository. And then, commits and pushes
# the changes.
- name: Push Packages
if: steps.rebuild_pkg.outputs.rebuilding_pkg == 'true'
run: |
# Find Debian Package
debfile=$(find /tmp/pkg/deb/ -name "*.deb" -type f -print -quit)
# Set up Git configuration
git config --global user.email "[email protected]"
git config --global user.name "MRDT-Software"
# Set up SSH key
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan github.com >> ~/.ssh/known_hosts
# Clone the destination repository using SSH
git clone [email protected]:MissouriMRDT/Autonomy_Packages.git
cd Autonomy_Packages
# Copy the new ARM64 packages into the repository
mkdir -p ${{ matrix.package }}/arm64/
cp -r /tmp/pkg/deb/*arm64*.deb ${{ matrix.package }}/arm64/
# Set up Git LFS
git lfs install
# Commit and push changes
git lfs track '*.deb'
git add .gitattributes
git add .
git commit -m "Upgrade ${{ matrix.package }} Package for AMD64"
git push origin main
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
# This step is used to remove the package from the temporary directory. It gets the list of packages that
# need to be rebuilt from the previous job. It removes the package from the temporary directory. This is
# done so that the next package can be built without having to worry about the previous package causing
# conflicts.
- name: Remove ${{ matrix.package }} Package
if: steps.rebuild_pkg.outputs.rebuilding_pkg == 'true'
run: rm -rf /tmp/pkg/*
- name: Cleanup Action Environment
if: always()
run: |
cd /opt
rm -rf /opt/Autonomy_Software
# This job is used to build and push the new jammy docker image. It is run on a self-hosted runner because
# there is not an NVIDIA GPU available on the GitHub runners. If this is being run on a pull request, then
# the image is tagged with the date and time. If this is being run on a push, then the image is tagged with
# the date and time and the latest tag. This job is run on both pushes and pull requests. And is allowed to run
# even if the previous job was skipped. This is because the previous job is only run on pull requests, but this
# job is run on pushes and pull requests.
build-and-push-jammy:
needs: [time-and-date, check-amd64-packages, build-updated-amd64-packages]
runs-on: [self-hosted, linux, X64]
timeout-minutes: 1440
if: ${{ always() && !failure() && !cancelled() }}
steps:
- name: Setup Action Environment
if: always()
run: |
cd /opt
if [ ! -d "Autonomy_Software" ]; then git clone --recurse-submodules -j8 https://github.com/MissouriMRDT/Autonomy_Software.git; fi
# This step is used to checkout the repository. It is needed so that the package build scripts can be
# checked for changes.
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
# This step is used to check if any of the package build scripts have been updated. If any of the package
# build scripts have been updated, then the packages need to be rebuilt in the next job. This step outputs
# a variable for each package that is set to true if the package needs to be rebuilt.
- name: Check for Updated Files
id: changes
uses: dorny/paths-filter@v3
with:
filters: |
dockerfile:
- '.devcontainer/Dockerfile_Jammy'
- '.github/workflows/deploy_docker.yml'
# This step is used to setup the docker buildx. It is needed to build the docker images.
- name: Setup Docker Buildx
if: steps.changes.outputs.dockerfile == 'true'
id: buildx
uses: docker/setup-buildx-action@v3
# This step is used to login to the GitHub Packages. It is needed to push the docker images.
- name: Login to GitHub Packages
if: steps.changes.outputs.dockerfile == 'true'
id: login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# This step is used to build and push the new jammy docker image. It is run on a self-hosted runner because
# there is not an NVIDIA GPU available on the GitHub runners. This step is only run on a pull request or a
# manual run. In either case the image is tagged with the date and time. It also saves a build cache so
# that the next time the image is built, it has the potential to be faster.
- name: Build and Push Jammy Image with Date Tag
if: ${{ ( github.event_name == 'pull_request' || ( github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/development' )) && (steps.changes.outputs.dockerfile == 'true') }}
uses: docker/build-push-action@v5
with:
context: ".devcontainer/"
file: ".devcontainer/Dockerfile_Jammy"
tags: |
"ghcr.io/missourimrdt/autonomy-jammy:buildcache"
"ghcr.io/missourimrdt/autonomy-jammy:${{ needs.time-and-date.outputs.date }}"
platforms: "linux/amd64"
push: true
cache-from: type=registry,ref=ghcr.io/missourimrdt/autonomy-jammy:buildcache
cache-to: type=registry,ref=ghcr.io/missourimrdt/autonomy-jammy:buildcache,mode=max
# This step is used to build and push the new jammy docker image. It is run on a self-hosted runner because
# there is not an NVIDIA GPU available on the GitHub runners. This step is only run on a push. In this case
# the image is tagged with the date and time and the latest tag. It also saves a build cache so that the
# next time the image is built, it has the potential to be faster.
- name: Build and Push Jammy Image with Latest Tag
if: ${{ github.event_name == 'push' && (steps.changes.outputs.dockerfile == 'true') }}
uses: docker/build-push-action@v5
with:
context: ".devcontainer/"
file: ".devcontainer/Dockerfile_Jammy"
tags: |
"ghcr.io/missourimrdt/autonomy-jammy:buildcache"
"ghcr.io/missourimrdt/autonomy-jammy:${{ needs.time-and-date.outputs.date }}"
"ghcr.io/missourimrdt/autonomy-jammy:latest"
platforms: "linux/amd64"
push: true
cache-from: type=registry,ref=ghcr.io/missourimrdt/autonomy-jammy:buildcache
cache-to: type=registry,ref=ghcr.io/missourimrdt/autonomy-jammy:buildcache,mode=max
- name: Cleanup Action Environment
if: always()
run: |
cd /opt
rm -rf /opt/Autonomy_Software
# This job is used to build and push the new jetpack docker image. It is run on a self-hosted runner because
# there is not an NVIDIA GPU available on the GitHub runners. If this is being run on a pull request, then
# the image is tagged with the date and time. If this is being run on a push, then the image is tagged with
# the date and time and the latest tag. This job is run on both pushes and pull requests. And is allowed to run
# even if the previous job was skipped. This is because the previous job is only run on pull requests, but this
# job is run on pushes and pull requests.
build-and-push-jetpack:
needs: [time-and-date, check-arm64-packages, build-updated-arm64-packages]
runs-on: [self-hosted, linux, ARM64]
timeout-minutes: 1440
if: ${{ always() && !failure() && !cancelled() }}
steps:
- name: Setup Action Environment
if: always()
run: |
cd /opt
if [ ! -d "Autonomy_Software" ]; then git clone --recurse-submodules -j8 https://github.com/MissouriMRDT/Autonomy_Software.git; fi
# This step is used to checkout the repository. It is needed so that the package build scripts can be
# checked for changes.
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: recursive
# This step is used to check if any of the package build scripts have been updated. If any of the package
# build scripts have been updated, then the packages need to be rebuilt in the next job. This step outputs
# a variable for each package that is set to true if the package needs to be rebuilt.
- name: Check for Updated Files
id: changes
uses: dorny/paths-filter@v3
with:
filters: |
dockerfile:
- '.devcontainer/Dockerfile_JetPack'
- '.github/workflows/deploy_docker.yml'
# This step is used to setup the docker buildx. It is needed to build the docker images.
- name: Setup Docker Buildx
if: steps.changes.outputs.dockerfile == 'true'
id: buildx
uses: docker/setup-buildx-action@v3
# This step is used to login to the GitHub Packages. It is needed to push the docker images.
- name: Login to GitHub Packages
if: steps.changes.outputs.dockerfile == 'true'
id: login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# This step is used to build and push the new jetpack docker image. It is run on a self-hosted runner
# because there is not an NVIDIA GPU available on the GitHub runners. This step is only run on a pull
# request or a manual run. In either case the image is tagged with the date and time. It also saves a
# build cache so that the next time the image is built, it has the potential to be faster.
- name: Build and Push JetPack Image with Date Tag
if: ${{ ( github.event_name == 'pull_request' || ( github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/development' )) && (steps.changes.outputs.dockerfile == 'true') }}
uses: docker/build-push-action@v5
with:
context: ".devcontainer/"
file: ".devcontainer/Dockerfile_JetPack"
tags: |
"ghcr.io/missourimrdt/autonomy-jetpack:buildcache"
"ghcr.io/missourimrdt/autonomy-jetpack:${{ needs.time-and-date.outputs.date }}"
platforms: "linux/arm64"
push: true
cache-from: type=registry,ref=ghcr.io/missourimrdt/autonomy-jetpack:buildcache
cache-to: type=registry,ref=ghcr.io/missourimrdt/autonomy-jetpack:buildcache,mode=max
# This step is used to build and push the new jetpack docker image. It is run on a self-hosted runner
# because there is not an NVIDIA GPU available on the GitHub runners. This step is only run on a push. In
# this case the image is tagged with the date and time and the latest tag. It also saves a build cache so
# that the next time the image is built, it has the potential to be faster.
- name: Build and Push JetPack Image with Latest Tag
if: ${{ github.event_name == 'push' && (steps.changes.outputs.dockerfile == 'true') }}
uses: docker/build-push-action@v5
with:
context: ".devcontainer/"
file: ".devcontainer/Dockerfile_JetPack"
tags: |
"ghcr.io/missourimrdt/autonomy-jetpack:buildcache"
"ghcr.io/missourimrdt/autonomy-jetpack:${{ needs.time-and-date.outputs.date }}"
"ghcr.io/missourimrdt/autonomy-jetpack:latest"
platforms: "linux/arm64"
push: true
cache-from: type=registry,ref=ghcr.io/missourimrdt/autonomy-jetpack:buildcache
cache-to: type=registry,ref=ghcr.io/missourimrdt/autonomy-jetpack:buildcache,mode=max
- name: Cleanup Action Environment
if: always()
run: |
cd /opt
rm -rf /opt/Autonomy_Software