From 1dd9ddb14f5e380602f6c8d25ebbe892deb93b04 Mon Sep 17 00:00:00 2001 From: Karolina Kozubik Date: Tue, 14 Apr 2026 19:47:31 +0200 Subject: [PATCH 1/5] feat: add reusaable workflows --- workflows/docker.yaml | 89 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 workflows/docker.yaml diff --git a/workflows/docker.yaml b/workflows/docker.yaml new file mode 100644 index 0000000..48af60f --- /dev/null +++ b/workflows/docker.yaml @@ -0,0 +1,89 @@ +name: Template - Build and Push Docker Image + +on: + workflow_call: + inputs: + image_name: + description: 'The name of the image (e.g., high-flyers/ros-core)' + required: true + type: string + dockerfile_path: + description: 'Path to the Dockerfile' + required: true + type: string + base_tag: + description: 'The base tag for the image (e.g., latest)' + required: false + type: string + default: latest + +env: + REGISTRY: ghcr.io + +jobs: + build: + strategy: + matrix: + include: + - arch: amd64 + runner: ubuntu-latest + platform: linux/amd64 + - arch: arm64 + runner: ubuntu-24.04-arm + platform: linux/arm64 + runs-on: ${{ matrix.runner }} + permissions: + contents: read + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to GHCR + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Set PR Tag Suffix + id: vars + run: | + if [[ "${{ github.event_name }}" == "pull_request" ]]; then + BRANCH_NAME="${{ github.head_ref }}" + SAFE_BRANCH=$(echo "$BRANCH_NAME" | tr '/' '-' | tr '[:upper:]' '[:lower:]') + echo "SUFFIX=-$SAFE_BRANCH" >> $GITHUB_OUTPUT + else + echo "SUFFIX=" >> $GITHUB_OUTPUT + fi + + - name: Build and push image + uses: docker/build-push-action@v5 + with: + context: . + file: ${{ inputs.dockerfile_path }} + push: true + platforms: ${{ matrix.platform }} + tags: | + ${{ env.REGISTRY }}/${{ inputs.image_name }}:${{ inputs.base_tag }}-${{ matrix.arch }}${{ steps.vars.outputs.SUFFIX }} + + manifest: + runs-on: ubuntu-latest + needs: build + if: github.event_name == 'push' + permissions: + packages: write + steps: + - name: Log in to GHCR + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Create and push multi-arch manifest + run: | + docker buildx imagetools create \ + -t ${{ env.REGISTRY }}/${{ inputs.image_name }}:${{ inputs.base_tag }} \ + ${{ env.REGISTRY }}/${{ inputs.image_name }}:${{ inputs.base_tag }}-amd64 \ + ${{ env.REGISTRY }}/${{ inputs.image_name }}:${{ inputs.base_tag }}-arm64 \ No newline at end of file From 142f9d6135dceae3fa364dfd02f93711d3a1c8ad Mon Sep 17 00:00:00 2001 From: Karolina Kozubik Date: Tue, 14 Apr 2026 19:54:16 +0200 Subject: [PATCH 2/5] feat: use workflows in this repo --- .github/workflows/docker-build-push.yaml | 83 ------------------------ .github/workflows/docker.yaml | 26 ++++++++ 2 files changed, 26 insertions(+), 83 deletions(-) delete mode 100644 .github/workflows/docker-build-push.yaml create mode 100644 .github/workflows/docker.yaml diff --git a/.github/workflows/docker-build-push.yaml b/.github/workflows/docker-build-push.yaml deleted file mode 100644 index dd33ddb..0000000 --- a/.github/workflows/docker-build-push.yaml +++ /dev/null @@ -1,83 +0,0 @@ -name: Build and Push Docker Image (native amd64 & arm64) - -on: - push: - branches: ["main", "workflow"] - pull_request: - -env: - REGISTRY: ghcr.io - IMAGE_NAME: high-flyers/ros-core - -jobs: - build: - strategy: - matrix: - ros_distro: [humble, jazzy] - arch: [amd64, arm64] - include: - - arch: amd64 - runner: ubuntu-latest - platform: linux/amd64 - - arch: arm64 - runner: ubuntu-24.04-arm - platform: linux/arm64 - runs-on: ${{ matrix.runner }} - permissions: - contents: read - packages: write - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Log in to GHCR - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Set image tags - id: vars - run: | - if [[ "${{ github.event_name }}" == "pull_request" ]]; then - BRANCH_NAME="${{ github.head_ref }}" - SAFE_BRANCH=$(echo "$BRANCH_NAME" | tr '/' '-' | tr '[:upper:]' '[:lower:]') - echo "TAG=-$SAFE_BRANCH" >> $GITHUB_OUTPUT - else - echo "TAG=" >> $GITHUB_OUTPUT - fi - - - name: Build and push image (${{ matrix.ros_distro }} - ${{ matrix.platform }}) - uses: docker/build-push-action@v5 - with: - context: . - file: ./images/ros-core-${{ matrix.ros_distro }}.Dockerfile - push: true - platforms: ${{ matrix.platform }} - tags: | - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.ros_distro }}-${{ matrix.arch }}${{ steps.vars.outputs.TAG }} - - manifest: - strategy: - matrix: - ros_distro: [humble, jazzy] - runs-on: ubuntu-latest - needs: build - if: github.event_name == 'push' - permissions: - packages: write - steps: - - name: Log in to GHCR - uses: docker/login-action@v3 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Create and push multi-arch manifest for ${{ matrix.ros_distro }} - run: | - docker buildx imagetools create \ - -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.ros_distro }} \ - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.ros_distro }}-amd64 \ - ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.ros_distro }}-arm64 diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml new file mode 100644 index 0000000..d7ed55e --- /dev/null +++ b/.github/workflows/docker.yaml @@ -0,0 +1,26 @@ +name: Build and Push Docker Image (native amd64 & arm64) + +on: + push: + branches: ["main", "workflow"] + pull_request: + +jobs: + docker-distros: + strategy: + matrix: + ros_distro: [humble, jazzy] + uses: ./workflows/docker.yaml + with: + image_name: high-flyers/ros-core + dockerfile_path: ./images/ros-core-${{ matrix.ros_distro }}.Dockerfile + base_tag: ${{ matrix.ros_distro }} + secrets: inherit + + docker-latest: + uses: ./workflows/docker.yaml + with: + image_name: high-flyers/ros-core + dockerfile_path: ./images/ros-core-humble.Dockerfile + base_tag: latest + secrets: inherit From 6c3d1d0b6072cfcf8a0650a2a6f31136b1bf74ce Mon Sep 17 00:00:00 2001 From: Karolina Kozubik Date: Tue, 14 Apr 2026 19:59:47 +0200 Subject: [PATCH 3/5] fix: correct intendation --- .github/workflows/docker.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index d7ed55e..e75d173 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -10,12 +10,12 @@ jobs: strategy: matrix: ros_distro: [humble, jazzy] - uses: ./workflows/docker.yaml - with: - image_name: high-flyers/ros-core - dockerfile_path: ./images/ros-core-${{ matrix.ros_distro }}.Dockerfile - base_tag: ${{ matrix.ros_distro }} - secrets: inherit + uses: ./workflows/docker.yaml + with: + image_name: high-flyers/ros-core + dockerfile_path: ./images/ros-core-${{ matrix.ros_distro }}.Dockerfile + base_tag: ${{ matrix.ros_distro }} + secrets: inherit docker-latest: uses: ./workflows/docker.yaml From 736a64a7a2aab4c9e2445493b3d2c4f489d1198c Mon Sep 17 00:00:00 2001 From: Karolina Kozubik Date: Tue, 14 Apr 2026 20:04:50 +0200 Subject: [PATCH 4/5] fix: move to .github --- .../docker.yaml => .github/workflows/docker-template.yaml | 0 .github/workflows/docker.yaml | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename workflows/docker.yaml => .github/workflows/docker-template.yaml (100%) diff --git a/workflows/docker.yaml b/.github/workflows/docker-template.yaml similarity index 100% rename from workflows/docker.yaml rename to .github/workflows/docker-template.yaml diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index e75d173..942c4ba 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -10,7 +10,7 @@ jobs: strategy: matrix: ros_distro: [humble, jazzy] - uses: ./workflows/docker.yaml + uses: ./github/workflows/docker-template.yaml with: image_name: high-flyers/ros-core dockerfile_path: ./images/ros-core-${{ matrix.ros_distro }}.Dockerfile @@ -18,7 +18,7 @@ jobs: secrets: inherit docker-latest: - uses: ./workflows/docker.yaml + uses: ./.github/workflows/docker-template.yaml with: image_name: high-flyers/ros-core dockerfile_path: ./images/ros-core-humble.Dockerfile From 6db5826c5f2e8b7f6b014f4feac8dc8181befbf0 Mon Sep 17 00:00:00 2001 From: Karolina Kozubik Date: Tue, 14 Apr 2026 20:06:54 +0200 Subject: [PATCH 5/5] fix: typo --- .github/workflows/docker.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 942c4ba..3ced894 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -10,7 +10,7 @@ jobs: strategy: matrix: ros_distro: [humble, jazzy] - uses: ./github/workflows/docker-template.yaml + uses: ./.github/workflows/docker-template.yaml with: image_name: high-flyers/ros-core dockerfile_path: ./images/ros-core-${{ matrix.ros_distro }}.Dockerfile