From ea65f6dd688bb09e2cc555833041b933dc90f119 Mon Sep 17 00:00:00 2001 From: Johnson Sun Date: Fri, 20 Sep 2024 23:26:49 +0800 Subject: [PATCH] ci(aloha_ws): Add automated build --- .github/workflows/build-aloha-ws.yaml | 61 +++++++++++++++++++++++++++ README.md | 2 +- 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build-aloha-ws.yaml diff --git a/.github/workflows/build-aloha-ws.yaml b/.github/workflows/build-aloha-ws.yaml new file mode 100644 index 00000000..8921bcbe --- /dev/null +++ b/.github/workflows/build-aloha-ws.yaml @@ -0,0 +1,61 @@ +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 + +jobs: + docker: + if: github.repository == 'j3soon/ros2-essentials' + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - 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: | + # This strips the git ref prefix from the version. + VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') + # This strips the "v" prefix from the tag name. + [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') + # This uses the Docker `latest` tag convention. + [ "$VERSION" == "main" ] && VERSION=latest + # Output the environment variable + # Ref: https://stackoverflow.com/a/57989070 + echo "VERSION=$VERSION" >> $GITHUB_ENV + - 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 + tags: | + type=raw,value={{date 'YYYYMMDD'}} + type=raw,value=${{ env.VERSION }} + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: aloha_ws/docker + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} diff --git a/README.md b/README.md index 457d884e..1954b21d 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Pulling the pre-built Docker images can bypass the time-consuming building proce | `j3soon/ros2-kobuki-ws` [[tags](https://hub.docker.com/r/j3soon/ros2-kobuki-ws/tags)][[code](./kobuki_ws)] | ✔️ | ✔️ | Real-world support | [Yu-Zhong Chen](https://github.com/YuZhong-Chen) | | `j3soon/ros2-vlp-ws` [[tags](https://hub.docker.com/r/j3soon/ros2-vlp-ws/tags)][[code](./vlp_ws)] | ✔️ | ✔️ | Real-world support | [Assume Zhan](https://github.com/Assume-Zhan) | | `j3soon/ros2-gazebo-world-ws` [[tags](https://hub.docker.com/r/j3soon/ros2-gazebo-world-ws/tags)][[code](./gazebo_world_ws)] | ✔️ | ❌️ | | [Yu-Zhong Chen](https://github.com/YuZhong-Chen) | -| `j3soon/aloha-ws` [[tags](https://hub.docker.com/r/j3soon/ros2-aloha-ws/tags)][[code](./aloha_ws)] | ✔️ | ❌️ | Simulation only | | +| `j3soon/aloha-ws` [[tags](https://hub.docker.com/r/j3soon/ros2-aloha-ws/tags)][[code](./aloha_ws)] | ✔️ | ✔️ | Simulation only | | ## Acknowledgement