Skip to content

Commit

Permalink
ci: Support git tag in github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
j3soon committed Sep 16, 2024
1 parent a58cfab commit c541590
Show file tree
Hide file tree
Showing 9 changed files with 174 additions and 86 deletions.
28 changes: 19 additions & 9 deletions .github/workflows/build-cartographer-ws.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches:
- "main"
tags:
- v*
paths:
- .github/workflows/build-cartographer-ws.yaml
- cartographer_ws/docker/Dockerfile
Expand All @@ -15,15 +17,25 @@ jobs:
if: github.repository == 'j3soon/ros2-essentials'
runs-on: ubuntu-latest
steps:
-
name: Checkout
- 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
-
name: Docker meta
- # 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
Expand All @@ -32,15 +44,13 @@ jobs:
images: ${{ secrets.DOCKERHUB_USERNAME }}/ros2-cartographer-ws
tags: |
type=raw,value={{date 'YYYYMMDD'}}
type=raw,value=latest
-
name: Login to Docker Hub
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
- name: Build and push
uses: docker/build-push-action@v4
with:
context: cartographer_ws/docker
Expand Down
28 changes: 19 additions & 9 deletions .github/workflows/build-gazebo-world-ws.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches:
- "main"
tags:
- v*
paths:
- .github/workflows/build-gazebo-world-ws.yaml
- gazebo_world_ws/docker/Dockerfile
Expand All @@ -15,11 +17,21 @@ jobs:
if: github.repository == 'j3soon/ros2-essentials'
runs-on: ubuntu-latest
steps:
-
name: Checkout
- name: Checkout
uses: actions/checkout@v3
-
name: Docker meta
- # 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
Expand All @@ -28,15 +40,13 @@ jobs:
images: ${{ secrets.DOCKERHUB_USERNAME }}/ros2-gazebo-world-ws
tags: |
type=raw,value={{date 'YYYYMMDD'}}
type=raw,value=latest
-
name: Login to Docker Hub
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
- name: Build and push
uses: docker/build-push-action@v4
with:
context: gazebo_world_ws/docker
Expand Down
28 changes: 19 additions & 9 deletions .github/workflows/build-husky-ws.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches:
- "main"
tags:
- v*
paths:
- .github/workflows/build-husky-ws.yaml
- husky_ws/docker/Dockerfile
Expand All @@ -18,15 +20,25 @@ jobs:
if: github.repository == 'j3soon/ros2-essentials'
runs-on: ubuntu-latest
steps:
-
name: Checkout
- 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
-
name: Docker meta
- # 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
Expand All @@ -35,15 +47,13 @@ jobs:
images: ${{ secrets.DOCKERHUB_USERNAME }}/ros2-husky-ws
tags: |
type=raw,value={{date 'YYYYMMDD'}}
type=raw,value=latest
-
name: Login to Docker Hub
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
- name: Build and push
uses: docker/build-push-action@v4
with:
context: husky_ws/docker
Expand Down
28 changes: 19 additions & 9 deletions .github/workflows/build-kobuki-ws.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches:
- "main"
tags:
- v*
paths:
- .github/workflows/build-kobuki-ws.yaml
- kobuki_ws/docker/Dockerfile
Expand All @@ -17,15 +19,25 @@ jobs:
if: github.repository == 'j3soon/ros2-essentials'
runs-on: ubuntu-latest
steps:
-
name: Checkout
- 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
-
name: Docker meta
- # 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
Expand All @@ -34,15 +46,13 @@ jobs:
images: ${{ secrets.DOCKERHUB_USERNAME }}/ros2-kobuki-ws
tags: |
type=raw,value={{date 'YYYYMMDD'}}
type=raw,value=latest
-
name: Login to Docker Hub
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
- name: Build and push
uses: docker/build-push-action@v4
with:
context: kobuki_ws/docker
Expand Down
28 changes: 19 additions & 9 deletions .github/workflows/build-orbslam3-ws.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches:
- "main"
tags:
- v*
paths:
- .github/workflows/build-orbslam3-ws.yaml
- orbslam3_ws/docker/Dockerfile
Expand All @@ -15,11 +17,21 @@ jobs:
if: github.repository == 'j3soon/ros2-essentials'
runs-on: ubuntu-latest
steps:
-
name: Checkout
- name: Checkout
uses: actions/checkout@v3
-
name: Docker meta
- # 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
Expand All @@ -28,15 +40,13 @@ jobs:
images: ${{ secrets.DOCKERHUB_USERNAME }}/ros2-orbslam3-ws
tags: |
type=raw,value={{date 'YYYYMMDD'}}
type=raw,value=latest
-
name: Login to Docker Hub
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
- name: Build and push
uses: docker/build-push-action@v4
with:
context: orbslam3_ws/docker
Expand Down
36 changes: 22 additions & 14 deletions .github/workflows/build-ros1-bridge-ws.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches:
- "main"
tags:
- v*
paths:
- .github/workflows/build-ros1-bridge-ws.yaml
- ros1_bridge_ws/docker/Dockerfile
Expand All @@ -18,15 +20,25 @@ jobs:
runs-on: self-hosted
timeout-minutes: 1440
steps:
-
name: Checkout
- 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
-
name: Docker meta
- # 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
Expand All @@ -35,9 +47,8 @@ jobs:
images: ${{ secrets.DOCKERHUB_USERNAME }}/ros2-ros1-bridge-ws
tags: |
type=raw,value={{date 'YYYYMMDD'}}
type=raw,value=latest
-
name: Docker meta (for build)
type=raw,value=${{ env.VERSION }}
- name: Docker meta (for build)
id: meta_build
# Ref: https://github.com/docker/metadata-action
uses: docker/metadata-action@v5
Expand All @@ -46,24 +57,21 @@ jobs:
images: ${{ secrets.DOCKERHUB_USERNAME }}/ros2-ros1-bridge-build-ws
tags: |
type=raw,value={{date 'YYYYMMDD'}}
type=raw,value=latest
-
name: Login to Docker Hub
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
- name: Build and push
uses: docker/build-push-action@v4
with:
context: ros1_bridge_ws/docker
target: release
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
-
name: Build and push
- name: Build and push
uses: docker/build-push-action@v4
with:
context: ros1_bridge_ws/docker
Expand Down
Loading

0 comments on commit c541590

Please sign in to comment.