Merge pull request #357 from MissouriMRDT/topic/sim-cam #311
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |