Supporting multi-arch Docker images #68
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2024 Dotanuki Labs | |
# SPDX-License-Identifier: MIT | |
name: CI | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
jobs: | |
checks: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Project Checkout | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- name: Lint Bash Scripts | |
uses: dotanuki-labs/github-actions/quality/bash@main | |
# - name: Run Component Tests | |
# run: ./component-tests.sh | |
build-docker-images: | |
needs: checks | |
runs-on: ${{ matrix.runner }} | |
strategy: | |
matrix: | |
runner: ["ubuntu22-amd64-medium", "ubuntu22-arm64-medium"] | |
steps: | |
- name: Project Checkout | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- name: Prepare build environment | |
id: docker-env | |
run: ./docker-build-helper.sh prepare-environment | |
- name: Extract Docker metadata | |
id: docker-metadata | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ github.repository }} | |
- name: Set up docker-buildx | |
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1 | |
- name: Log in to Github Container Registry | |
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build container Image | |
id: build | |
uses: docker/build-push-action@5cd11c3a4ced054e52742c5fd54dca954e0edd85 # v6.7.0 | |
with: | |
platforms: linux/${{ steps.docker-env.outputs.platform }} | |
labels: ${{ steps.docker-metadata.outputs.labels }} | |
outputs: type=image,name=${{ github.repository }},push-by-digest=true,name-canonical=true,push=true | |
- name: Export build digest | |
run: ./docker-build-helper.sh collect-digest ${{ steps.build.outputs.digest }}" | |
- name: Upload digest | |
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 | |
with: | |
name: digests-${{ steps.docker-env.outputs.platform }} | |
path: /tmp/digests/* | |
merge-manifests: | |
runs-on: ubuntu-22.04 | |
needs: build-docker-images | |
steps: | |
- name: Download digests | |
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 | |
with: | |
path: /tmp/digests | |
pattern: digests-* | |
merge-multiple: true | |
- name: Set up docker-buildx | |
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db # v3.6.1 | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ github.repository }} | |
- name: Log in to Github Container Registry | |
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create and push merged manifest | |
working-directory: /tmp/digests | |
run: ./docker-build-helper.sh update-manifest ${{ github.repository }}" | |
- name: Inspect image | |
run: docker buildx imagetools inspect ${{ github.repository }}:${{ steps.meta.outputs.version }} |