diff --git a/.github/workflows/push_gisnav_images.yml b/.github/workflows/push_gisnav_images.yml new file mode 100644 index 00000000..6c9d0ef8 --- /dev/null +++ b/.github/workflows/push_gisnav_images.yml @@ -0,0 +1,49 @@ +name: Push latest GISNav multi-arch Docker images to GHCR + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + + # Allows running manually from the Actions tab + workflow_dispatch: + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + upload: + runs-on: ubuntu-20.04 + timeout-minutes: 120 + defaults: + run: + shell: bash + steps: + - name: Checkout GISNav + uses: actions/checkout@v3 + with: + path: colcon_ws/src/gisnav + + - name: Login to GHCR + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract git tag from GITHUB_REF + run: echo "TAG=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_ENV + if: startsWith(github.ref, 'refs/tags/') + + - name: Setup Docker Buildx + run: | + docker buildx create --use + + # TODO: try to use docker-compose.yaml file to avoid having to specify redundant build args here + - name: Build and push GISNav multi-arch Docker images + run: | + cd colcon_ws/src/gisnav + docker buildx build --build-arg ROS_VERSION=humble --push --platform linux/amd64,linux/arm64 -f docker/gisnav/Dockerfile -t ghcr.io/hmakelin/gisnav:${TAG:-latest} . + diff --git a/.github/workflows/run_ros2_launch_tests.yml b/.github/workflows/run_ros2_launch_tests.yml index 87671616..70fd174c 100644 --- a/.github/workflows/run_ros2_launch_tests.yml +++ b/.github/workflows/run_ros2_launch_tests.yml @@ -2,7 +2,7 @@ name: Run ROS 2 launch tests on: workflow_run: - workflows: [ "Build and upload gisnav Docker image to GHCR" ] + workflows: [ "Push latest GISNav multi-arch Docker images to GHCR" ] types: - completed diff --git a/.github/workflows/run_unit_tests.yml b/.github/workflows/run_unit_tests.yml index 40a81f4c..07e5a652 100644 --- a/.github/workflows/run_unit_tests.yml +++ b/.github/workflows/run_unit_tests.yml @@ -2,7 +2,7 @@ name: Run unit tests on: workflow_run: - workflows: [ "Build and upload gisnav Docker image to GHCR" ] + workflows: [ "Push latest GISNav multi-arch Docker images to GHCR" ] types: - completed diff --git a/.github/workflows/static_analysis.yml b/.github/workflows/static_analysis.yml index d36fdab8..39ad640d 100644 --- a/.github/workflows/static_analysis.yml +++ b/.github/workflows/static_analysis.yml @@ -2,7 +2,7 @@ name: Static analysis on: workflow_run: - workflows: [ "Build and upload gisnav Docker image to GHCR" ] + workflows: [ "Push latest GISNav multi-arch Docker images to GHCR" ] types: - completed diff --git a/.github/workflows/upload_gisnav_image.yml b/.github/workflows/upload_gisnav_image.yml deleted file mode 100644 index e564141b..00000000 --- a/.github/workflows/upload_gisnav_image.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Build and upload gisnav Docker image to GHCR - -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] - - # Allows running manually from the Actions tab - workflow_dispatch: - -env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} - -jobs: - upload: - runs-on: ubuntu-20.04 - defaults: - run: - shell: bash - steps: - - name: Checkout GISNav - uses: actions/checkout@v3 - with: - path: colcon_ws/src/gisnav - - - name: Login to GHCR - uses: docker/login-action@v2 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push gisnav image - run: | - cd colcon_ws/src/gisnav/docker - docker compose build gisnav - docker tag $(docker images -q gisnav) ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest - docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest diff --git a/docker/docker-compose.yaml b/docker/docker-compose.yaml index a2a293d5..4a4f43cc 100644 --- a/docker/docker-compose.yaml +++ b/docker/docker-compose.yaml @@ -83,17 +83,17 @@ services: privileged: true # Note: build context is repository root + # Note 2: The "docker buildx build" command in the push_gisnav_images.yml workflow + # duplicates these build arguments. They should be changed together. gisnav: <<: [*base, *ros, *tty, *nvidia-gpu] + #image: "ghcr.io/hmakelin/gisnav:${TAG:-latest}" + image: ghcr.io/hmakelin/gisnav:latest build: context: .. dockerfile: docker/gisnav/Dockerfile args: ROS_VERSION: humble - #platforms: - # - "linux/amd64" - # - "linux/arm64" - image: gisnav # used by GitHub upload_gisnav_image CI workflow command: ros2 launch gisnav px4.dev.launch.py px4: