From 024f52a2bb8a58ad20c03a067560215e8cef6307 Mon Sep 17 00:00:00 2001 From: Johnson Sun Date: Fri, 13 Dec 2024 16:54:20 +0800 Subject: [PATCH 1/2] ci: Reuse docker cache To allow docker cache reuse across images, we need to build the template workspace first, then build the other workspaces. This can be done by using the `workflow_run` event to trigger the build of the other workspaces. Since `workflow_run` does not natively support path matching, the `paths-filter` action is used to identify changed files and determine whether a workspace build is needed. Unfortunately, the paths-filter action does not function as intended when used with the workflow_run event due to the loss of commit information. To address this limitation, a workaround involving the use of artifacts between workflows is implemented to transfer the missing information. Since transferring artifacts across workflows is not natively supported, the community-provided download-artifact action variant is utilized. To allow the use of remote build cache, a non-default builder is required, which can be enabled by `docker/setup-buildx-action`. We can then use `--cache-from` and `--cache-to` flags to specify the cache. The dedicated cache registry and `max` mode seems to be required instead of the `inline` mode due to the use of multi-platform images and multi-stage builds. I'm not 100% sure if this is required though. References: * dorny/paths-filter * https://github.com/dorny/paths-filter?tab=readme-ov-file#examples * https://stackoverflow.com/a/70711156 * workflow_run * https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#onworkflow_runbranchesbranches-ignore * https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#workflow_run * docker build cache * https://docs.docker.com/build/cache/backends/ * https://docs.docker.com/build/cache/backends/inline/ * https://docs.docker.com/build/cache/backends/registry/ * docker builder * https://docs.docker.com/build/builders/drivers/ * https://yuki-nakamura.com/2024/01/20/use-buildkit-from-docker-compose/ * https://docs.docker.com/reference/cli/docker/buildx/create/ * https://github.com/docker/buildx/blob/master/README.md#set-buildx-as-the-default-builder * https://github.com/docker/buildx/discussions/2142#discussioncomment-7682295 --- .github/workflows/build-aloha-ws.yaml | 94 +++++++++++++++---- .github/workflows/build-cartographer-ws.yaml | 90 ++++++++++++++---- .github/workflows/build-docs.yaml | 6 +- .github/workflows/build-gazebo-world-ws.yaml | 85 +++++++++++++---- .github/workflows/build-husky-ws.yaml | 96 ++++++++++++++++---- .github/workflows/build-kobuki-ws.yaml | 94 +++++++++++++++---- .github/workflows/build-orbslam3-ws.yaml | 85 +++++++++++++---- .github/workflows/build-ros1-bridge-ws.yaml | 16 ++-- .github/workflows/build-rtabmap-ws.yaml | 85 +++++++++++++---- .github/workflows/build-template-ws.yaml | 72 ++++++++++++--- .github/workflows/build-vlp-ws.yaml | 90 ++++++++++++++---- 11 files changed, 657 insertions(+), 156 deletions(-) diff --git a/.github/workflows/build-aloha-ws.yaml b/.github/workflows/build-aloha-ws.yaml index 374d89f6..7b2f3180 100644 --- a/.github/workflows/build-aloha-ws.yaml +++ b/.github/workflows/build-aloha-ws.yaml @@ -1,22 +1,51 @@ name: Build Docker Image for aloha-ws on: - push: - branches: - - "main" - tags: - - v* - paths: - - .github/workflows/build-aloha-ws.yaml - - aloha_ws/docker/Dockerfile - - aloha_ws/docker/.dockerignore - - aloha_ws/docker/.bashrc - - aloha_ws/docker/script/** - - aloha_ws/docker/udev_rules/** + workflow_run: + workflows: ["Build Docker Image for template-ws"] + types: [completed] jobs: + paths-filter: + if: ${{ github.event.workflow_run.conclusion == 'success' }} + runs-on: ubuntu-latest + outputs: + results: ${{ steps.filter.outputs.results }} + steps: + # Ref: https://github.com/dorny/paths-filter/issues/147#issuecomment-1287800590 + - name: Download a single artifact + uses: dawidd6/action-download-artifact@v7 + with: + workflow: build-template-ws.yaml + name: original-refs + workflow_conclusion: success + - name: set REF_BASE to env + run: | + echo "BASE=$(cat base.txt)" >> $GITHUB_ENV + echo "CURRENT_BRANCH=$(cat current-branch.txt)" >> $GITHUB_ENV + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: filter + with: + base: ${{ env.BASE }} + ref: ${{ env.CURRENT_BRANCH }} + filters: | + results: + - .github/workflows/build-aloha-ws.yaml + - aloha_ws/docker/Dockerfile + - aloha_ws/docker/.dockerignore + - aloha_ws/docker/.bashrc + - aloha_ws/docker/script/** + - aloha_ws/docker/udev_rules/** + - name: Changes matched + if: steps.filter.outputs.results == 'true' + run: echo "Changes matched, will build image" + - name: Changes didn't match + if: steps.filter.outputs.results != 'true' + run: echo "Changes didn't match, will NOT build image" docker: - if: github.repository == 'j3soon/ros2-essentials' + needs: paths-filter + if: ${{ needs.paths-filter.outputs.results == 'true' }} runs-on: ubuntu-latest steps: - name: Maximize build space @@ -31,7 +60,7 @@ jobs: - name: Restart docker run: sudo service docker restart - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx @@ -48,25 +77,54 @@ jobs: # Output the environment variable # Ref: https://stackoverflow.com/a/57989070 echo "VERSION=$VERSION" >> $GITHUB_ENV + # Print for debugging purpose + echo "VERSION=$VERSION" - name: Docker meta id: meta # Ref: https://github.com/docker/metadata-action uses: docker/metadata-action@v5 with: # Link: https://hub.docker.com/repository/docker/j3soon/ros2-aloha-ws/tags - images: ${{ secrets.DOCKERHUB_USERNAME }}/ros2-aloha-ws + images: j3soon/ros2-aloha-ws tags: | type=raw,value={{date 'YYYYMMDD'}} type=raw,value=${{ env.VERSION }} - name: Login to Docker Hub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} + username: j3soon password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Pull j3soon/ros2-template-ws (amd64) + run: docker pull --platform linux/amd64 j3soon/ros2-template-ws + - name: Pull j3soon/ros2-template-ws (arm64) + run: docker pull --platform linux/arm64 j3soon/ros2-template-ws - name: Build and push - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v6 with: context: aloha_ws/docker + cache-from: | + j3soon/ros2-template-ws:buildcache-amd64 + j3soon/ros2-template-ws:buildcache-arm64 platforms: linux/amd64,linux/arm64 push: true tags: ${{ steps.meta.outputs.tags }} + - name: Push amd64 cache + uses: docker/build-push-action@v6 + with: + context: aloha_ws/docker + cache-from: | + j3soon/ros2-template-ws:buildcache-amd64 + j3soon/ros2-template-ws:buildcache-arm64 + cache-to: type=registry,ref=j3soon/ros2-aloha-ws:buildcache-amd64,mode=max + platforms: linux/amd64 + tags: ${{ steps.meta.outputs.tags }} + - name: Push arm64 cache + uses: docker/build-push-action@v6 + with: + context: aloha_ws/docker + cache-from: | + j3soon/ros2-template-ws:buildcache-amd64 + j3soon/ros2-template-ws:buildcache-arm64 + cache-to: type=registry,ref=j3soon/ros2-aloha-ws:buildcache-arm64,mode=max + platforms: linux/arm64 + tags: ${{ steps.meta.outputs.tags }} diff --git a/.github/workflows/build-cartographer-ws.yaml b/.github/workflows/build-cartographer-ws.yaml index 5640a5c5..461ca4e9 100644 --- a/.github/workflows/build-cartographer-ws.yaml +++ b/.github/workflows/build-cartographer-ws.yaml @@ -1,20 +1,49 @@ name: Build Docker Image for cartographer-ws on: - push: - branches: - - "main" - tags: - - v* - paths: - - .github/workflows/build-cartographer-ws.yaml - - cartographer_ws/docker/Dockerfile - - cartographer_ws/docker/.dockerignore - - cartographer_ws/docker/.bashrc + workflow_run: + workflows: ["Build Docker Image for template-ws"] + types: [completed] jobs: + paths-filter: + if: ${{ github.event.workflow_run.conclusion == 'success' }} + runs-on: ubuntu-latest + outputs: + results: ${{ steps.filter.outputs.results }} + steps: + # Ref: https://github.com/dorny/paths-filter/issues/147#issuecomment-1287800590 + - name: Download a single artifact + uses: dawidd6/action-download-artifact@v7 + with: + workflow: build-template-ws.yaml + name: original-refs + workflow_conclusion: success + - name: set REF_BASE to env + run: | + echo "BASE=$(cat base.txt)" >> $GITHUB_ENV + echo "CURRENT_BRANCH=$(cat current-branch.txt)" >> $GITHUB_ENV + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: filter + with: + base: ${{ env.BASE }} + ref: ${{ env.CURRENT_BRANCH }} + filters: | + results: + - .github/workflows/build-cartographer-ws.yaml + - cartographer_ws/docker/Dockerfile + - cartographer_ws/docker/.dockerignore + - cartographer_ws/docker/.bashrc + - name: Changes matched + if: steps.filter.outputs.results == 'true' + run: echo "Changes matched, will build image" + - name: Changes didn't match + if: steps.filter.outputs.results != 'true' + run: echo "Changes didn't match, will NOT build image" docker: - if: github.repository == 'j3soon/ros2-essentials' + needs: paths-filter + if: ${{ needs.paths-filter.outputs.results == 'true' }} runs-on: ubuntu-latest steps: - name: Maximize build space @@ -29,7 +58,7 @@ jobs: - name: Restart docker run: sudo service docker restart - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx @@ -46,25 +75,54 @@ jobs: # Output the environment variable # Ref: https://stackoverflow.com/a/57989070 echo "VERSION=$VERSION" >> $GITHUB_ENV + # Print for debugging purpose + echo "VERSION=$VERSION" - name: Docker meta id: meta # Ref: https://github.com/docker/metadata-action uses: docker/metadata-action@v5 with: # Link: https://hub.docker.com/repository/docker/j3soon/ros2-cartographer-ws/tags - images: ${{ secrets.DOCKERHUB_USERNAME }}/ros2-cartographer-ws + images: j3soon/ros2-cartographer-ws tags: | type=raw,value={{date 'YYYYMMDD'}} type=raw,value=${{ env.VERSION }} - name: Login to Docker Hub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} + username: j3soon password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Pull j3soon/ros2-template-ws (amd64) + run: docker pull --platform linux/amd64 j3soon/ros2-template-ws + - name: Pull j3soon/ros2-template-ws (arm64) + run: docker pull --platform linux/arm64 j3soon/ros2-template-ws - name: Build and push - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v6 with: context: cartographer_ws/docker + cache-from: | + j3soon/ros2-template-ws:buildcache-amd64 + j3soon/ros2-template-ws:buildcache-arm64 platforms: linux/amd64,linux/arm64 push: true tags: ${{ steps.meta.outputs.tags }} + - name: Push amd64 cache + uses: docker/build-push-action@v6 + with: + context: cartographer_ws/docker + cache-from: | + j3soon/ros2-template-ws:buildcache-amd64 + j3soon/ros2-template-ws:buildcache-arm64 + cache-to: type=registry,ref=j3soon/ros2-cartographer-ws:buildcache-amd64,mode=max + platforms: linux/amd64 + tags: ${{ steps.meta.outputs.tags }} + - name: Push arm64 cache + uses: docker/build-push-action@v6 + with: + context: cartographer_ws/docker + cache-from: | + j3soon/ros2-template-ws:buildcache-amd64 + j3soon/ros2-template-ws:buildcache-arm64 + cache-to: type=registry,ref=j3soon/ros2-cartographer-ws:buildcache-arm64,mode=max + platforms: linux/arm64 + tags: ${{ steps.meta.outputs.tags }} diff --git a/.github/workflows/build-docs.yaml b/.github/workflows/build-docs.yaml index 2219d308..9b2cb97d 100644 --- a/.github/workflows/build-docs.yaml +++ b/.github/workflows/build-docs.yaml @@ -14,14 +14,14 @@ jobs: if: github.repository == 'j3soon/ros2-essentials' runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # Ref: https://github.com/timvink/mkdocs-git-revision-date-localized-plugin#note-when-using-build-environments with: fetch-depth: '0' - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: 3.x - - uses: actions/cache@v2 + - uses: actions/cache@v4 with: key: ${{ github.ref }} path: .cache diff --git a/.github/workflows/build-gazebo-world-ws.yaml b/.github/workflows/build-gazebo-world-ws.yaml index a83c344c..d6548dab 100644 --- a/.github/workflows/build-gazebo-world-ws.yaml +++ b/.github/workflows/build-gazebo-world-ws.yaml @@ -1,20 +1,49 @@ name: Build Docker Image for gazebo-world-ws on: - push: - branches: - - "main" - tags: - - v* - paths: - - .github/workflows/build-gazebo-world-ws.yaml - - gazebo_world_ws/docker/Dockerfile - - gazebo_world_ws/docker/.dockerignore - - gazebo_world_ws/docker/.bashrc + workflow_run: + workflows: ["Build Docker Image for template-ws"] + types: [completed] jobs: + paths-filter: + if: ${{ github.event.workflow_run.conclusion == 'success' }} + runs-on: ubuntu-latest + outputs: + results: ${{ steps.filter.outputs.results }} + steps: + # Ref: https://github.com/dorny/paths-filter/issues/147#issuecomment-1287800590 + - name: Download a single artifact + uses: dawidd6/action-download-artifact@v7 + with: + workflow: build-template-ws.yaml + name: original-refs + workflow_conclusion: success + - name: set REF_BASE to env + run: | + echo "BASE=$(cat base.txt)" >> $GITHUB_ENV + echo "CURRENT_BRANCH=$(cat current-branch.txt)" >> $GITHUB_ENV + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: filter + with: + base: ${{ env.BASE }} + ref: ${{ env.CURRENT_BRANCH }} + filters: | + results: + - .github/workflows/build-gazebo-world-ws.yaml + - gazebo_world_ws/docker/Dockerfile + - gazebo_world_ws/docker/.dockerignore + - gazebo_world_ws/docker/.bashrc + - name: Changes matched + if: steps.filter.outputs.results == 'true' + run: echo "Changes matched, will build image" + - name: Changes didn't match + if: steps.filter.outputs.results != 'true' + run: echo "Changes didn't match, will NOT build image" docker: - if: github.repository == 'j3soon/ros2-essentials' + needs: paths-filter + if: ${{ needs.paths-filter.outputs.results == 'true' }} runs-on: ubuntu-latest steps: - name: Maximize build space @@ -29,7 +58,11 @@ jobs: - name: Restart docker run: sudo service docker restart - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - # Ref: https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#upgrading-a-workflow-that-accesses-a-registry-using-a-personal-access-token name: Prepare tag name as environment variable run: | @@ -42,24 +75,44 @@ jobs: # Output the environment variable # Ref: https://stackoverflow.com/a/57989070 echo "VERSION=$VERSION" >> $GITHUB_ENV + # Print for debugging purpose + echo "VERSION=$VERSION" - name: Docker meta id: meta # Ref: https://github.com/docker/metadata-action uses: docker/metadata-action@v5 with: # Link: https://hub.docker.com/repository/docker/j3soon/ros2-gazebo-world-ws/tags - images: ${{ secrets.DOCKERHUB_USERNAME }}/ros2-gazebo-world-ws + images: j3soon/ros2-gazebo-world-ws tags: | type=raw,value={{date 'YYYYMMDD'}} type=raw,value=${{ env.VERSION }} - name: Login to Docker Hub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} + username: j3soon password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Pull j3soon/ros2-template-ws (amd64) + run: docker pull --platform linux/amd64 j3soon/ros2-template-ws + - name: Pull j3soon/ros2-template-ws (arm64) + run: docker pull --platform linux/arm64 j3soon/ros2-template-ws - name: Build and push - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v6 with: context: gazebo_world_ws/docker + cache-from: | + j3soon/ros2-template-ws:buildcache-amd64 + j3soon/ros2-template-ws:buildcache-arm64 + platforms: linux/amd64 push: true tags: ${{ steps.meta.outputs.tags }} + - name: Push amd64 cache + uses: docker/build-push-action@v6 + with: + context: gazebo_world_ws/docker + cache-from: | + j3soon/ros2-template-ws:buildcache-amd64 + j3soon/ros2-template-ws:buildcache-arm64 + cache-to: type=registry,ref=j3soon/ros2-gazebo-world-ws:buildcache-amd64,mode=max + platforms: linux/amd64 + tags: ${{ steps.meta.outputs.tags }} diff --git a/.github/workflows/build-husky-ws.yaml b/.github/workflows/build-husky-ws.yaml index 645ad1b4..63ad6e3e 100644 --- a/.github/workflows/build-husky-ws.yaml +++ b/.github/workflows/build-husky-ws.yaml @@ -1,23 +1,52 @@ name: Build Docker Image for husky-ws on: - push: - branches: - - "main" - tags: - - v* - paths: - - .github/workflows/build-husky-ws.yaml - - husky_ws/docker/Dockerfile - - husky_ws/docker/.dockerignore - - husky_ws/docker/.bashrc - - husky_ws/docker/script/** - - husky_ws/docker/clearpath_computer_installer/** - - husky_ws/docker/udev_rules/** + workflow_run: + workflows: ["Build Docker Image for template-ws"] + types: [completed] jobs: + paths-filter: + if: ${{ github.event.workflow_run.conclusion == 'success' }} + runs-on: ubuntu-latest + outputs: + results: ${{ steps.filter.outputs.results }} + steps: + # Ref: https://github.com/dorny/paths-filter/issues/147#issuecomment-1287800590 + - name: Download a single artifact + uses: dawidd6/action-download-artifact@v7 + with: + workflow: build-template-ws.yaml + name: original-refs + workflow_conclusion: success + - name: set REF_BASE to env + run: | + echo "BASE=$(cat base.txt)" >> $GITHUB_ENV + echo "CURRENT_BRANCH=$(cat current-branch.txt)" >> $GITHUB_ENV + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: filter + with: + base: ${{ env.BASE }} + ref: ${{ env.CURRENT_BRANCH }} + filters: | + results: + - .github/workflows/build-husky-ws.yaml + - husky_ws/docker/Dockerfile + - husky_ws/docker/.dockerignore + - husky_ws/docker/.bashrc + - husky_ws/docker/script/** + - husky_ws/docker/clearpath_computer_installer/** + - husky_ws/docker/udev_rules/** + - name: Changes matched + if: steps.filter.outputs.results == 'true' + run: echo "Changes matched, will build image" + - name: Changes didn't match + if: steps.filter.outputs.results != 'true' + run: echo "Changes didn't match, will NOT build image" docker: - if: github.repository == 'j3soon/ros2-essentials' + needs: paths-filter + if: ${{ needs.paths-filter.outputs.results == 'true' }} runs-on: ubuntu-latest steps: - name: Maximize build space @@ -32,7 +61,7 @@ jobs: - name: Restart docker run: sudo service docker restart - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx @@ -49,25 +78,54 @@ jobs: # Output the environment variable # Ref: https://stackoverflow.com/a/57989070 echo "VERSION=$VERSION" >> $GITHUB_ENV + # Print for debugging purpose + echo "VERSION=$VERSION" - name: Docker meta id: meta # Ref: https://github.com/docker/metadata-action uses: docker/metadata-action@v5 with: # Link: https://hub.docker.com/repository/docker/j3soon/ros2-husky-ws/tags - images: ${{ secrets.DOCKERHUB_USERNAME }}/ros2-husky-ws + images: j3soon/ros2-husky-ws tags: | type=raw,value={{date 'YYYYMMDD'}} type=raw,value=${{ env.VERSION }} - name: Login to Docker Hub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} + username: j3soon password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Pull j3soon/ros2-template-ws (amd64) + run: docker pull --platform linux/amd64 j3soon/ros2-template-ws + - name: Pull j3soon/ros2-template-ws (arm64) + run: docker pull --platform linux/arm64 j3soon/ros2-template-ws - name: Build and push - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v6 with: context: husky_ws/docker + cache-from: | + j3soon/ros2-template-ws:buildcache-amd64 + j3soon/ros2-template-ws:buildcache-arm64 platforms: linux/amd64,linux/arm64 push: true tags: ${{ steps.meta.outputs.tags }} + - name: Push amd64 cache + uses: docker/build-push-action@v6 + with: + context: husky_ws/docker + cache-from: | + j3soon/ros2-template-ws:buildcache-amd64 + j3soon/ros2-template-ws:buildcache-arm64 + cache-to: type=registry,ref=j3soon/ros2-husky-ws:buildcache-amd64,mode=max + platforms: linux/amd64 + tags: ${{ steps.meta.outputs.tags }} + - name: Push arm64 cache + uses: docker/build-push-action@v6 + with: + context: husky_ws/docker + cache-from: | + j3soon/ros2-template-ws:buildcache-amd64 + j3soon/ros2-template-ws:buildcache-arm64 + cache-to: type=registry,ref=j3soon/ros2-husky-ws:buildcache-arm64,mode=max + platforms: linux/arm64 + tags: ${{ steps.meta.outputs.tags }} diff --git a/.github/workflows/build-kobuki-ws.yaml b/.github/workflows/build-kobuki-ws.yaml index beeeb9b7..749ee62e 100644 --- a/.github/workflows/build-kobuki-ws.yaml +++ b/.github/workflows/build-kobuki-ws.yaml @@ -1,22 +1,51 @@ name: Build Docker Image for kobuki-ws on: - push: - branches: - - "main" - tags: - - v* - paths: - - .github/workflows/build-kobuki-ws.yaml - - kobuki_ws/docker/Dockerfile - - kobuki_ws/docker/.dockerignore - - kobuki_ws/docker/.bashrc - - kobuki_ws/docker/kobuki_driver_ws/** - - kobuki_ws/docker/udev_rules/** + workflow_run: + workflows: ["Build Docker Image for template-ws"] + types: [completed] jobs: + paths-filter: + if: ${{ github.event.workflow_run.conclusion == 'success' }} + runs-on: ubuntu-latest + outputs: + results: ${{ steps.filter.outputs.results }} + steps: + # Ref: https://github.com/dorny/paths-filter/issues/147#issuecomment-1287800590 + - name: Download a single artifact + uses: dawidd6/action-download-artifact@v7 + with: + workflow: build-template-ws.yaml + name: original-refs + workflow_conclusion: success + - name: set REF_BASE to env + run: | + echo "BASE=$(cat base.txt)" >> $GITHUB_ENV + echo "CURRENT_BRANCH=$(cat current-branch.txt)" >> $GITHUB_ENV + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: filter + with: + base: ${{ env.BASE }} + ref: ${{ env.CURRENT_BRANCH }} + filters: | + results: + - .github/workflows/build-kobuki-ws.yaml + - kobuki_ws/docker/Dockerfile + - kobuki_ws/docker/.dockerignore + - kobuki_ws/docker/.bashrc + - kobuki_ws/docker/kobuki_driver_ws/** + - kobuki_ws/docker/udev_rules/** + - name: Changes matched + if: steps.filter.outputs.results == 'true' + run: echo "Changes matched, will build image" + - name: Changes didn't match + if: steps.filter.outputs.results != 'true' + run: echo "Changes didn't match, will NOT build image" docker: - if: github.repository == 'j3soon/ros2-essentials' + needs: paths-filter + if: ${{ needs.paths-filter.outputs.results == 'true' }} runs-on: ubuntu-latest steps: - name: Maximize build space @@ -31,7 +60,7 @@ jobs: - name: Restart docker run: sudo service docker restart - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx @@ -48,25 +77,54 @@ jobs: # Output the environment variable # Ref: https://stackoverflow.com/a/57989070 echo "VERSION=$VERSION" >> $GITHUB_ENV + # Print for debugging purpose + echo "VERSION=$VERSION" - name: Docker meta id: meta # Ref: https://github.com/docker/metadata-action uses: docker/metadata-action@v5 with: # Link: https://hub.docker.com/repository/docker/j3soon/ros2-kobuki-ws/tags - images: ${{ secrets.DOCKERHUB_USERNAME }}/ros2-kobuki-ws + images: j3soon/ros2-kobuki-ws tags: | type=raw,value={{date 'YYYYMMDD'}} type=raw,value=${{ env.VERSION }} - name: Login to Docker Hub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} + username: j3soon password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Pull j3soon/ros2-template-ws (amd64) + run: docker pull --platform linux/amd64 j3soon/ros2-template-ws + - name: Pull j3soon/ros2-template-ws (arm64) + run: docker pull --platform linux/arm64 j3soon/ros2-template-ws - name: Build and push - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v6 with: context: kobuki_ws/docker + cache-from: | + j3soon/ros2-template-ws:buildcache-amd64 + j3soon/ros2-template-ws:buildcache-arm64 platforms: linux/amd64,linux/arm64 push: true tags: ${{ steps.meta.outputs.tags }} + - name: Push amd64 cache + uses: docker/build-push-action@v6 + with: + context: kobuki_ws/docker + cache-from: | + j3soon/ros2-template-ws:buildcache-amd64 + j3soon/ros2-template-ws:buildcache-arm64 + cache-to: type=registry,ref=j3soon/ros2-kobuki-ws:buildcache-amd64,mode=max + platforms: linux/amd64 + tags: ${{ steps.meta.outputs.tags }} + - name: Push arm64 cache + uses: docker/build-push-action@v6 + with: + context: kobuki_ws/docker + cache-from: | + j3soon/ros2-template-ws:buildcache-amd64 + j3soon/ros2-template-ws:buildcache-arm64 + cache-to: type=registry,ref=j3soon/ros2-kobuki-ws:buildcache-arm64,mode=max + platforms: linux/arm64 + tags: ${{ steps.meta.outputs.tags }} diff --git a/.github/workflows/build-orbslam3-ws.yaml b/.github/workflows/build-orbslam3-ws.yaml index 7c57efac..a7f959eb 100644 --- a/.github/workflows/build-orbslam3-ws.yaml +++ b/.github/workflows/build-orbslam3-ws.yaml @@ -1,20 +1,49 @@ name: Build Docker Image for orbslam3-ws on: - push: - branches: - - "main" - tags: - - v* - paths: - - .github/workflows/build-orbslam3-ws.yaml - - orbslam3_ws/docker/Dockerfile - - orbslam3_ws/docker/.dockerignore - - orbslam3_ws/docker/.bashrc + workflow_run: + workflows: ["Build Docker Image for template-ws"] + types: [completed] jobs: + paths-filter: + if: ${{ github.event.workflow_run.conclusion == 'success' }} + runs-on: ubuntu-latest + outputs: + results: ${{ steps.filter.outputs.results }} + steps: + # Ref: https://github.com/dorny/paths-filter/issues/147#issuecomment-1287800590 + - name: Download a single artifact + uses: dawidd6/action-download-artifact@v7 + with: + workflow: build-template-ws.yaml + name: original-refs + workflow_conclusion: success + - name: set REF_BASE to env + run: | + echo "BASE=$(cat base.txt)" >> $GITHUB_ENV + echo "CURRENT_BRANCH=$(cat current-branch.txt)" >> $GITHUB_ENV + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: filter + with: + base: ${{ env.BASE }} + ref: ${{ env.CURRENT_BRANCH }} + filters: | + results: + - .github/workflows/build-orbslam3-ws.yaml + - orbslam3_ws/docker/Dockerfile + - orbslam3_ws/docker/.dockerignore + - orbslam3_ws/docker/.bashrc + - name: Changes matched + if: steps.filter.outputs.results == 'true' + run: echo "Changes matched, will build image" + - name: Changes didn't match + if: steps.filter.outputs.results != 'true' + run: echo "Changes didn't match, will NOT build image" docker: - if: github.repository == 'j3soon/ros2-essentials' + needs: paths-filter + if: ${{ needs.paths-filter.outputs.results == 'true' }} runs-on: ubuntu-latest steps: - name: Maximize build space @@ -29,7 +58,11 @@ jobs: - name: Restart docker run: sudo service docker restart - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - # Ref: https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#upgrading-a-workflow-that-accesses-a-registry-using-a-personal-access-token name: Prepare tag name as environment variable run: | @@ -42,24 +75,44 @@ jobs: # Output the environment variable # Ref: https://stackoverflow.com/a/57989070 echo "VERSION=$VERSION" >> $GITHUB_ENV + # Print for debugging purpose + echo "VERSION=$VERSION" - name: Docker meta id: meta # Ref: https://github.com/docker/metadata-action uses: docker/metadata-action@v5 with: # Link: https://hub.docker.com/repository/docker/j3soon/ros2-orbslam3-ws/tags - images: ${{ secrets.DOCKERHUB_USERNAME }}/ros2-orbslam3-ws + images: j3soon/ros2-orbslam3-ws tags: | type=raw,value={{date 'YYYYMMDD'}} type=raw,value=${{ env.VERSION }} - name: Login to Docker Hub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} + username: j3soon password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Pull j3soon/ros2-template-ws (amd64) + run: docker pull --platform linux/amd64 j3soon/ros2-template-ws + - name: Pull j3soon/ros2-template-ws (arm64) + run: docker pull --platform linux/arm64 j3soon/ros2-template-ws - name: Build and push - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v6 with: context: orbslam3_ws/docker + cache-from: | + j3soon/ros2-template-ws:buildcache-amd64 + j3soon/ros2-template-ws:buildcache-arm64 + platforms: linux/amd64 push: true tags: ${{ steps.meta.outputs.tags }} + - name: Push amd64 cache + uses: docker/build-push-action@v6 + with: + context: orbslam3_ws/docker + cache-from: | + j3soon/ros2-template-ws:buildcache-amd64 + j3soon/ros2-template-ws:buildcache-arm64 + cache-to: type=registry,ref=j3soon/ros2-orbslam3-ws:buildcache-amd64,mode=max + platforms: linux/amd64 + tags: ${{ steps.meta.outputs.tags }} diff --git a/.github/workflows/build-ros1-bridge-ws.yaml b/.github/workflows/build-ros1-bridge-ws.yaml index d32dc409..ed914ce6 100644 --- a/.github/workflows/build-ros1-bridge-ws.yaml +++ b/.github/workflows/build-ros1-bridge-ws.yaml @@ -21,7 +21,7 @@ jobs: timeout-minutes: 1440 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx @@ -38,13 +38,15 @@ jobs: # Output the environment variable # Ref: https://stackoverflow.com/a/57989070 echo "VERSION=$VERSION" >> $GITHUB_ENV + # Print for debugging purpose + echo "VERSION=$VERSION" - name: Docker meta id: meta # Ref: https://github.com/docker/metadata-action uses: docker/metadata-action@v5 with: # Link: https://hub.docker.com/repository/docker/j3soon/ros2-ros1-bridge-ws/tags - images: ${{ secrets.DOCKERHUB_USERNAME }}/ros2-ros1-bridge-ws + images: j3soon/ros2-ros1-bridge-ws tags: | type=raw,value={{date 'YYYYMMDD'}} type=raw,value=${{ env.VERSION }} @@ -54,17 +56,17 @@ jobs: uses: docker/metadata-action@v5 with: # Link: https://hub.docker.com/repository/docker/j3soon/ros2-ros1-bridge-build-ws/tags - images: ${{ secrets.DOCKERHUB_USERNAME }}/ros2-ros1-bridge-build-ws + images: j3soon/ros2-ros1-bridge-build-ws tags: | type=raw,value={{date 'YYYYMMDD'}} type=raw,value=${{ env.VERSION }} - name: Login to Docker Hub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} + username: j3soon password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v6 with: context: ros1_bridge_ws/docker target: release @@ -72,7 +74,7 @@ jobs: push: true tags: ${{ steps.meta.outputs.tags }} - name: Build and push - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v6 with: context: ros1_bridge_ws/docker target: build diff --git a/.github/workflows/build-rtabmap-ws.yaml b/.github/workflows/build-rtabmap-ws.yaml index 112fe9a7..7bb92b1a 100644 --- a/.github/workflows/build-rtabmap-ws.yaml +++ b/.github/workflows/build-rtabmap-ws.yaml @@ -1,20 +1,49 @@ name: Build Docker Image for rtabmap-ws on: - push: - branches: - - "main" - tags: - - v* - paths: - - .github/workflows/build-rtabmap-ws.yaml - - rtabmap_ws/docker/Dockerfile - - rtabmap_ws/docker/.dockerignore - - rtabmap_ws/docker/.bashrc + workflow_run: + workflows: ["Build Docker Image for template-ws"] + types: [completed] jobs: + paths-filter: + if: ${{ github.event.workflow_run.conclusion == 'success' }} + runs-on: ubuntu-latest + outputs: + results: ${{ steps.filter.outputs.results }} + steps: + # Ref: https://github.com/dorny/paths-filter/issues/147#issuecomment-1287800590 + - name: Download a single artifact + uses: dawidd6/action-download-artifact@v7 + with: + workflow: build-template-ws.yaml + name: original-refs + workflow_conclusion: success + - name: set REF_BASE to env + run: | + echo "BASE=$(cat base.txt)" >> $GITHUB_ENV + echo "CURRENT_BRANCH=$(cat current-branch.txt)" >> $GITHUB_ENV + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: filter + with: + base: ${{ env.BASE }} + ref: ${{ env.CURRENT_BRANCH }} + filters: | + results: + - .github/workflows/build-rtabmap-ws.yaml + - rtabmap_ws/docker/Dockerfile + - rtabmap_ws/docker/.dockerignore + - rtabmap_ws/docker/.bashrc + - name: Changes matched + if: steps.filter.outputs.results == 'true' + run: echo "Changes matched, will build image" + - name: Changes didn't match + if: steps.filter.outputs.results != 'true' + run: echo "Changes didn't match, will NOT build image" docker: - if: github.repository == 'j3soon/ros2-essentials' + needs: paths-filter + if: ${{ needs.paths-filter.outputs.results == 'true' }} runs-on: ubuntu-latest steps: - name: Maximize build space @@ -29,7 +58,11 @@ jobs: - name: Restart docker run: sudo service docker restart - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - # Ref: https://docs.github.com/en/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions#upgrading-a-workflow-that-accesses-a-registry-using-a-personal-access-token name: Prepare tag name as environment variable run: | @@ -42,24 +75,44 @@ jobs: # Output the environment variable # Ref: https://stackoverflow.com/a/57989070 echo "VERSION=$VERSION" >> $GITHUB_ENV + # Print for debugging purpose + echo "VERSION=$VERSION" - name: Docker meta id: meta # Ref: https://github.com/docker/metadata-action uses: docker/metadata-action@v5 with: # Link: https://hub.docker.com/repository/docker/j3soon/ros2-rtabmap-ws/tags - images: ${{ secrets.DOCKERHUB_USERNAME }}/ros2-rtabmap-ws + images: j3soon/ros2-rtabmap-ws tags: | type=raw,value={{date 'YYYYMMDD'}} type=raw,value=${{ env.VERSION }} - name: Login to Docker Hub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} + username: j3soon password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Pull j3soon/ros2-template-ws (amd64) + run: docker pull --platform linux/amd64 j3soon/ros2-template-ws + - name: Pull j3soon/ros2-template-ws (arm64) + run: docker pull --platform linux/arm64 j3soon/ros2-template-ws - name: Build and push - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v6 with: context: rtabmap_ws/docker + cache-from: | + j3soon/ros2-template-ws:buildcache-amd64 + j3soon/ros2-template-ws:buildcache-arm64 + platforms: linux/amd64 push: true tags: ${{ steps.meta.outputs.tags }} + - name: Push amd64 cache + uses: docker/build-push-action@v6 + with: + context: rtabmap_ws/docker + cache-from: | + j3soon/ros2-template-ws:buildcache-amd64 + j3soon/ros2-template-ws:buildcache-arm64 + cache-to: type=registry,ref=j3soon/ros2-rtabmap-ws:buildcache-amd64,mode=max + platforms: linux/amd64 + tags: ${{ steps.meta.outputs.tags }} diff --git a/.github/workflows/build-template-ws.yaml b/.github/workflows/build-template-ws.yaml index bc6963a1..04a7b7a0 100644 --- a/.github/workflows/build-template-ws.yaml +++ b/.github/workflows/build-template-ws.yaml @@ -6,16 +6,49 @@ on: - "main" tags: - v* - paths: - - .github/workflows/build-template-ws.yaml - - template_ws/docker/Dockerfile - - template_ws/docker/.dockerignore - - template_ws/docker/.bashrc jobs: - docker: + paths-filter: if: github.repository == 'j3soon/ros2-essentials' runs-on: ubuntu-latest + outputs: + results: ${{ steps.filter.outputs.results }} + steps: + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + results: + - .github/workflows/build-template-ws.yaml + - template_ws/docker/Dockerfile + - template_ws/docker/.dockerignore + - template_ws/docker/.bashrc + - name: Changes matched + if: steps.filter.outputs.results == 'true' + run: echo "Changes matched, will build image" + - name: Changes didn't match + if: steps.filter.outputs.results != 'true' + run: echo "Changes didn't match, will NOT build image" + # Ref: https://github.com/dorny/paths-filter/issues/147#issuecomment-1287800590 + - name: Save base ref info + run: | + BASE=${{ github.event.before }} + CURRENT_BRANCH=${{ github.ref }} + echo $BASE > base.txt + echo $CURRENT_BRANCH > current-branch.txt + - name: Upload base ref info + uses: actions/upload-artifact@v4 + with: + name: original-refs + path: | + base.txt + current-branch.txt + retention-days: 1 + docker: + needs: paths-filter + if: ${{ needs.paths-filter.outputs.results == 'true' }} + runs-on: ubuntu-latest steps: - name: Maximize build space uses: easimon/maximize-build-space@master @@ -29,7 +62,7 @@ jobs: - name: Restart docker run: sudo service docker restart - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx @@ -46,25 +79,42 @@ jobs: # Output the environment variable # Ref: https://stackoverflow.com/a/57989070 echo "VERSION=$VERSION" >> $GITHUB_ENV + # Print for debugging purpose + echo "VERSION=$VERSION" - name: Docker meta id: meta # Ref: https://github.com/docker/metadata-action uses: docker/metadata-action@v5 with: # Link: https://hub.docker.com/repository/docker/j3soon/ros2-template-ws/tags - images: ${{ secrets.DOCKERHUB_USERNAME }}/ros2-template-ws + images: j3soon/ros2-template-ws tags: | type=raw,value={{date 'YYYYMMDD'}} type=raw,value=${{ env.VERSION }} - name: Login to Docker Hub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} + username: j3soon password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v6 with: context: template_ws/docker platforms: linux/amd64,linux/arm64 push: true tags: ${{ steps.meta.outputs.tags }} + # Ref: https://github.com/docker/buildx/discussions/1382#discussioncomment-6252049 + - name: Push amd64 cache + uses: docker/build-push-action@v6 + with: + context: template_ws/docker + cache-to: type=registry,ref=j3soon/ros2-template-ws:buildcache-amd64,mode=max + platforms: linux/amd64 + tags: ${{ steps.meta.outputs.tags }} + - name: Push arm64 cache + uses: docker/build-push-action@v6 + with: + context: template_ws/docker + cache-to: type=registry,ref=j3soon/ros2-template-ws:buildcache-arm64,mode=max + platforms: linux/arm64 + tags: ${{ steps.meta.outputs.tags }} diff --git a/.github/workflows/build-vlp-ws.yaml b/.github/workflows/build-vlp-ws.yaml index 77da9706..465638b9 100644 --- a/.github/workflows/build-vlp-ws.yaml +++ b/.github/workflows/build-vlp-ws.yaml @@ -1,20 +1,49 @@ name: Build Docker Image for vlp-ws on: - push: - branches: - - "main" - tags: - - v* - paths: - - .github/workflows/build-vlp-ws.yaml - - vlp_ws/docker/Dockerfile - - vlp_ws/docker/.dockerignore - - vlp_ws/docker/.bashrc + workflow_run: + workflows: ["Build Docker Image for template-ws"] + types: [completed] jobs: + paths-filter: + if: ${{ github.event.workflow_run.conclusion == 'success' }} + runs-on: ubuntu-latest + outputs: + results: ${{ steps.filter.outputs.results }} + steps: + # Ref: https://github.com/dorny/paths-filter/issues/147#issuecomment-1287800590 + - name: Download a single artifact + uses: dawidd6/action-download-artifact@v7 + with: + workflow: build-template-ws.yaml + name: original-refs + workflow_conclusion: success + - name: set REF_BASE to env + run: | + echo "BASE=$(cat base.txt)" >> $GITHUB_ENV + echo "CURRENT_BRANCH=$(cat current-branch.txt)" >> $GITHUB_ENV + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: filter + with: + base: ${{ env.BASE }} + ref: ${{ env.CURRENT_BRANCH }} + filters: | + results: + - .github/workflows/build-vlp-ws.yaml + - vlp_ws/docker/Dockerfile + - vlp_ws/docker/.dockerignore + - vlp_ws/docker/.bashrc + - name: Changes matched + if: steps.filter.outputs.results == 'true' + run: echo "Changes matched, will build image" + - name: Changes didn't match + if: steps.filter.outputs.results != 'true' + run: echo "Changes didn't match, will NOT build image" docker: - if: github.repository == 'j3soon/ros2-essentials' + needs: paths-filter + if: ${{ needs.paths-filter.outputs.results == 'true' }} runs-on: ubuntu-latest steps: - name: Maximize build space @@ -29,7 +58,7 @@ jobs: - name: Restart docker run: sudo service docker restart - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx @@ -46,25 +75,54 @@ jobs: # Output the environment variable # Ref: https://stackoverflow.com/a/57989070 echo "VERSION=$VERSION" >> $GITHUB_ENV + # Print for debugging purpose + echo "VERSION=$VERSION" - name: Docker meta id: meta # Ref: https://github.com/docker/metadata-action uses: docker/metadata-action@v5 with: # Link: https://hub.docker.com/repository/docker/j3soon/ros2-vlp-ws/tags - images: ${{ secrets.DOCKERHUB_USERNAME }}/ros2-vlp-ws + images: j3soon/ros2-vlp-ws tags: | type=raw,value={{date 'YYYYMMDD'}} type=raw,value=${{ env.VERSION }} - name: Login to Docker Hub - uses: docker/login-action@v2 + uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} + username: j3soon password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Pull j3soon/ros2-template-ws (amd64) + run: docker pull --platform linux/amd64 j3soon/ros2-template-ws + - name: Pull j3soon/ros2-template-ws (arm64) + run: docker pull --platform linux/arm64 j3soon/ros2-template-ws - name: Build and push - uses: docker/build-push-action@v4 + uses: docker/build-push-action@v6 with: context: vlp_ws/docker + cache-from: | + j3soon/ros2-template-ws:buildcache-amd64 + j3soon/ros2-template-ws:buildcache-arm64 platforms: linux/amd64,linux/arm64 push: true tags: ${{ steps.meta.outputs.tags }} + - name: Push amd64 cache + uses: docker/build-push-action@v6 + with: + context: vlp_ws/docker + cache-from: | + j3soon/ros2-template-ws:buildcache-amd64 + j3soon/ros2-template-ws:buildcache-arm64 + cache-to: type=registry,ref=j3soon/ros2-vlp-ws:buildcache-amd64,mode=max + platforms: linux/amd64 + tags: ${{ steps.meta.outputs.tags }} + - name: Push arm64 cache + uses: docker/build-push-action@v6 + with: + context: vlp_ws/docker + cache-from: | + j3soon/ros2-template-ws:buildcache-amd64 + j3soon/ros2-template-ws:buildcache-arm64 + cache-to: type=registry,ref=j3soon/ros2-vlp-ws:buildcache-arm64,mode=max + platforms: linux/arm64 + tags: ${{ steps.meta.outputs.tags }} From cdc0b1332393284f4cf98a80b7bb0c7e266a2f47 Mon Sep 17 00:00:00 2001 From: Johnson Sun Date: Sat, 14 Dec 2024 03:05:16 +0800 Subject: [PATCH 2/2] ci: Push image after cache For correctly getting latest image tag for docs --- .github/workflows/build-aloha-ws.yaml | 13 +++++++++++-- .github/workflows/build-cartographer-ws.yaml | 13 +++++++++++-- .github/workflows/build-gazebo-world-ws.yaml | 13 +++++++++++-- .github/workflows/build-husky-ws.yaml | 13 +++++++++++-- .github/workflows/build-kobuki-ws.yaml | 13 +++++++++++-- .github/workflows/build-orbslam3-ws.yaml | 13 +++++++++++-- .github/workflows/build-rtabmap-ws.yaml | 13 +++++++++++-- .github/workflows/build-template-ws.yaml | 10 ++++++++-- .github/workflows/build-vlp-ws.yaml | 13 +++++++++++-- 9 files changed, 96 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build-aloha-ws.yaml b/.github/workflows/build-aloha-ws.yaml index 7b2f3180..a447e067 100644 --- a/.github/workflows/build-aloha-ws.yaml +++ b/.github/workflows/build-aloha-ws.yaml @@ -98,7 +98,7 @@ jobs: run: docker pull --platform linux/amd64 j3soon/ros2-template-ws - name: Pull j3soon/ros2-template-ws (arm64) run: docker pull --platform linux/arm64 j3soon/ros2-template-ws - - name: Build and push + - name: Build image uses: docker/build-push-action@v6 with: context: aloha_ws/docker @@ -106,7 +106,6 @@ jobs: j3soon/ros2-template-ws:buildcache-amd64 j3soon/ros2-template-ws:buildcache-arm64 platforms: linux/amd64,linux/arm64 - push: true tags: ${{ steps.meta.outputs.tags }} - name: Push amd64 cache uses: docker/build-push-action@v6 @@ -128,3 +127,13 @@ jobs: cache-to: type=registry,ref=j3soon/ros2-aloha-ws:buildcache-arm64,mode=max platforms: linux/arm64 tags: ${{ steps.meta.outputs.tags }} + - name: Push image + uses: docker/build-push-action@v6 + with: + context: aloha_ws/docker + cache-from: | + j3soon/ros2-template-ws:buildcache-amd64 + j3soon/ros2-template-ws:buildcache-arm64 + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} diff --git a/.github/workflows/build-cartographer-ws.yaml b/.github/workflows/build-cartographer-ws.yaml index 461ca4e9..52b29906 100644 --- a/.github/workflows/build-cartographer-ws.yaml +++ b/.github/workflows/build-cartographer-ws.yaml @@ -96,7 +96,7 @@ jobs: run: docker pull --platform linux/amd64 j3soon/ros2-template-ws - name: Pull j3soon/ros2-template-ws (arm64) run: docker pull --platform linux/arm64 j3soon/ros2-template-ws - - name: Build and push + - name: Build image uses: docker/build-push-action@v6 with: context: cartographer_ws/docker @@ -104,7 +104,6 @@ jobs: j3soon/ros2-template-ws:buildcache-amd64 j3soon/ros2-template-ws:buildcache-arm64 platforms: linux/amd64,linux/arm64 - push: true tags: ${{ steps.meta.outputs.tags }} - name: Push amd64 cache uses: docker/build-push-action@v6 @@ -126,3 +125,13 @@ jobs: cache-to: type=registry,ref=j3soon/ros2-cartographer-ws:buildcache-arm64,mode=max platforms: linux/arm64 tags: ${{ steps.meta.outputs.tags }} + - name: Push image + uses: docker/build-push-action@v6 + with: + context: cartographer_ws/docker + cache-from: | + j3soon/ros2-template-ws:buildcache-amd64 + j3soon/ros2-template-ws:buildcache-arm64 + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} diff --git a/.github/workflows/build-gazebo-world-ws.yaml b/.github/workflows/build-gazebo-world-ws.yaml index d6548dab..c9f94823 100644 --- a/.github/workflows/build-gazebo-world-ws.yaml +++ b/.github/workflows/build-gazebo-world-ws.yaml @@ -96,7 +96,7 @@ jobs: run: docker pull --platform linux/amd64 j3soon/ros2-template-ws - name: Pull j3soon/ros2-template-ws (arm64) run: docker pull --platform linux/arm64 j3soon/ros2-template-ws - - name: Build and push + - name: Build image uses: docker/build-push-action@v6 with: context: gazebo_world_ws/docker @@ -104,7 +104,6 @@ jobs: j3soon/ros2-template-ws:buildcache-amd64 j3soon/ros2-template-ws:buildcache-arm64 platforms: linux/amd64 - push: true tags: ${{ steps.meta.outputs.tags }} - name: Push amd64 cache uses: docker/build-push-action@v6 @@ -116,3 +115,13 @@ jobs: cache-to: type=registry,ref=j3soon/ros2-gazebo-world-ws:buildcache-amd64,mode=max platforms: linux/amd64 tags: ${{ steps.meta.outputs.tags }} + - name: Push image + uses: docker/build-push-action@v6 + with: + context: gazebo_world_ws/docker + cache-from: | + j3soon/ros2-template-ws:buildcache-amd64 + j3soon/ros2-template-ws:buildcache-arm64 + platforms: linux/amd64 + push: true + tags: ${{ steps.meta.outputs.tags }} diff --git a/.github/workflows/build-husky-ws.yaml b/.github/workflows/build-husky-ws.yaml index 63ad6e3e..3f4f23c0 100644 --- a/.github/workflows/build-husky-ws.yaml +++ b/.github/workflows/build-husky-ws.yaml @@ -99,7 +99,7 @@ jobs: run: docker pull --platform linux/amd64 j3soon/ros2-template-ws - name: Pull j3soon/ros2-template-ws (arm64) run: docker pull --platform linux/arm64 j3soon/ros2-template-ws - - name: Build and push + - name: Build image uses: docker/build-push-action@v6 with: context: husky_ws/docker @@ -107,7 +107,6 @@ jobs: j3soon/ros2-template-ws:buildcache-amd64 j3soon/ros2-template-ws:buildcache-arm64 platforms: linux/amd64,linux/arm64 - push: true tags: ${{ steps.meta.outputs.tags }} - name: Push amd64 cache uses: docker/build-push-action@v6 @@ -129,3 +128,13 @@ jobs: cache-to: type=registry,ref=j3soon/ros2-husky-ws:buildcache-arm64,mode=max platforms: linux/arm64 tags: ${{ steps.meta.outputs.tags }} + - name: Push image + uses: docker/build-push-action@v6 + with: + context: husky_ws/docker + cache-from: | + j3soon/ros2-template-ws:buildcache-amd64 + j3soon/ros2-template-ws:buildcache-arm64 + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} diff --git a/.github/workflows/build-kobuki-ws.yaml b/.github/workflows/build-kobuki-ws.yaml index 749ee62e..1adf30b4 100644 --- a/.github/workflows/build-kobuki-ws.yaml +++ b/.github/workflows/build-kobuki-ws.yaml @@ -98,7 +98,7 @@ jobs: run: docker pull --platform linux/amd64 j3soon/ros2-template-ws - name: Pull j3soon/ros2-template-ws (arm64) run: docker pull --platform linux/arm64 j3soon/ros2-template-ws - - name: Build and push + - name: Build image uses: docker/build-push-action@v6 with: context: kobuki_ws/docker @@ -106,7 +106,6 @@ jobs: j3soon/ros2-template-ws:buildcache-amd64 j3soon/ros2-template-ws:buildcache-arm64 platforms: linux/amd64,linux/arm64 - push: true tags: ${{ steps.meta.outputs.tags }} - name: Push amd64 cache uses: docker/build-push-action@v6 @@ -128,3 +127,13 @@ jobs: cache-to: type=registry,ref=j3soon/ros2-kobuki-ws:buildcache-arm64,mode=max platforms: linux/arm64 tags: ${{ steps.meta.outputs.tags }} + - name: Push image + uses: docker/build-push-action@v6 + with: + context: kobuki_ws/docker + cache-from: | + j3soon/ros2-template-ws:buildcache-amd64 + j3soon/ros2-template-ws:buildcache-arm64 + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} diff --git a/.github/workflows/build-orbslam3-ws.yaml b/.github/workflows/build-orbslam3-ws.yaml index a7f959eb..99a041b1 100644 --- a/.github/workflows/build-orbslam3-ws.yaml +++ b/.github/workflows/build-orbslam3-ws.yaml @@ -96,7 +96,7 @@ jobs: run: docker pull --platform linux/amd64 j3soon/ros2-template-ws - name: Pull j3soon/ros2-template-ws (arm64) run: docker pull --platform linux/arm64 j3soon/ros2-template-ws - - name: Build and push + - name: Build image uses: docker/build-push-action@v6 with: context: orbslam3_ws/docker @@ -104,7 +104,6 @@ jobs: j3soon/ros2-template-ws:buildcache-amd64 j3soon/ros2-template-ws:buildcache-arm64 platforms: linux/amd64 - push: true tags: ${{ steps.meta.outputs.tags }} - name: Push amd64 cache uses: docker/build-push-action@v6 @@ -116,3 +115,13 @@ jobs: cache-to: type=registry,ref=j3soon/ros2-orbslam3-ws:buildcache-amd64,mode=max platforms: linux/amd64 tags: ${{ steps.meta.outputs.tags }} + - name: Push image + uses: docker/build-push-action@v6 + with: + context: orbslam3_ws/docker + cache-from: | + j3soon/ros2-template-ws:buildcache-amd64 + j3soon/ros2-template-ws:buildcache-arm64 + platforms: linux/amd64 + push: true + tags: ${{ steps.meta.outputs.tags }} diff --git a/.github/workflows/build-rtabmap-ws.yaml b/.github/workflows/build-rtabmap-ws.yaml index 7bb92b1a..1b69eddb 100644 --- a/.github/workflows/build-rtabmap-ws.yaml +++ b/.github/workflows/build-rtabmap-ws.yaml @@ -96,7 +96,7 @@ jobs: run: docker pull --platform linux/amd64 j3soon/ros2-template-ws - name: Pull j3soon/ros2-template-ws (arm64) run: docker pull --platform linux/arm64 j3soon/ros2-template-ws - - name: Build and push + - name: Build image uses: docker/build-push-action@v6 with: context: rtabmap_ws/docker @@ -104,7 +104,6 @@ jobs: j3soon/ros2-template-ws:buildcache-amd64 j3soon/ros2-template-ws:buildcache-arm64 platforms: linux/amd64 - push: true tags: ${{ steps.meta.outputs.tags }} - name: Push amd64 cache uses: docker/build-push-action@v6 @@ -116,3 +115,13 @@ jobs: cache-to: type=registry,ref=j3soon/ros2-rtabmap-ws:buildcache-amd64,mode=max platforms: linux/amd64 tags: ${{ steps.meta.outputs.tags }} + - name: Push image + uses: docker/build-push-action@v6 + with: + context: rtabmap_ws/docker + cache-from: | + j3soon/ros2-template-ws:buildcache-amd64 + j3soon/ros2-template-ws:buildcache-arm64 + platforms: linux/amd64 + push: true + tags: ${{ steps.meta.outputs.tags }} diff --git a/.github/workflows/build-template-ws.yaml b/.github/workflows/build-template-ws.yaml index 04a7b7a0..5de9efe0 100644 --- a/.github/workflows/build-template-ws.yaml +++ b/.github/workflows/build-template-ws.yaml @@ -96,12 +96,11 @@ jobs: with: username: j3soon password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Build and push + - name: Build image uses: docker/build-push-action@v6 with: context: template_ws/docker platforms: linux/amd64,linux/arm64 - push: true tags: ${{ steps.meta.outputs.tags }} # Ref: https://github.com/docker/buildx/discussions/1382#discussioncomment-6252049 - name: Push amd64 cache @@ -118,3 +117,10 @@ jobs: cache-to: type=registry,ref=j3soon/ros2-template-ws:buildcache-arm64,mode=max platforms: linux/arm64 tags: ${{ steps.meta.outputs.tags }} + - name: Push image + uses: docker/build-push-action@v6 + with: + context: template_ws/docker + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} diff --git a/.github/workflows/build-vlp-ws.yaml b/.github/workflows/build-vlp-ws.yaml index 465638b9..763e402b 100644 --- a/.github/workflows/build-vlp-ws.yaml +++ b/.github/workflows/build-vlp-ws.yaml @@ -96,7 +96,7 @@ jobs: run: docker pull --platform linux/amd64 j3soon/ros2-template-ws - name: Pull j3soon/ros2-template-ws (arm64) run: docker pull --platform linux/arm64 j3soon/ros2-template-ws - - name: Build and push + - name: Build image uses: docker/build-push-action@v6 with: context: vlp_ws/docker @@ -104,7 +104,6 @@ jobs: j3soon/ros2-template-ws:buildcache-amd64 j3soon/ros2-template-ws:buildcache-arm64 platforms: linux/amd64,linux/arm64 - push: true tags: ${{ steps.meta.outputs.tags }} - name: Push amd64 cache uses: docker/build-push-action@v6 @@ -126,3 +125,13 @@ jobs: cache-to: type=registry,ref=j3soon/ros2-vlp-ws:buildcache-arm64,mode=max platforms: linux/arm64 tags: ${{ steps.meta.outputs.tags }} + - name: Push image + uses: docker/build-push-action@v6 + with: + context: vlp_ws/docker + cache-from: | + j3soon/ros2-template-ws:buildcache-amd64 + j3soon/ros2-template-ws:buildcache-arm64 + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }}