diff --git a/.github/workflows/build-aloha-ws.yaml b/.github/workflows/build-aloha-ws.yaml index 374d89f6..a447e067 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,63 @@ 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: Build and push - uses: docker/build-push-action@v4 + - 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 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 + 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 }} + - 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 5640a5c5..52b29906 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,63 @@ 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: Build and push - uses: docker/build-push-action@v4 + - 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 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 + 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 }} + - 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-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..c9f94823 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,53 @@ 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: Build and push - uses: docker/build-push-action@v4 + - 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 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 + 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 }} + - 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 645ad1b4..3f4f23c0 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,63 @@ 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: Build and push - uses: docker/build-push-action@v4 + - 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 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 + 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 }} + - 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 beeeb9b7..1adf30b4 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,63 @@ 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: Build and push - uses: docker/build-push-action@v4 + - 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 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 + 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 }} + - 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 7c57efac..99a041b1 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,53 @@ 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: Build and push - uses: docker/build-push-action@v4 + - 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 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 + 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 }} + - 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-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..1b69eddb 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,53 @@ 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: Build and push - uses: docker/build-push-action@v4 + - 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 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 + 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 }} + - 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 bc6963a1..5de9efe0 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,23 +79,46 @@ 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 + - name: Build image + uses: docker/build-push-action@v6 + with: + context: template_ws/docker + platforms: linux/amd64,linux/arm64 + 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 }} + - name: Push image + uses: docker/build-push-action@v6 with: context: template_ws/docker platforms: linux/amd64,linux/arm64 diff --git a/.github/workflows/build-vlp-ws.yaml b/.github/workflows/build-vlp-ws.yaml index 77da9706..763e402b 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,63 @@ 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: Build and push - uses: docker/build-push-action@v4 + - 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 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 + 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 }} + - 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 }}