Add GitHub Actions workflow to build run-gitmanager images #3
Workflow file for this run
This file contains hidden or 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
| name: Build and push Docker image | |
| on: | |
| push: | |
| tags: | |
| - 'v[0-9]*' | |
| jobs: | |
| build: | |
| name: Build (${{ matrix.platform }}) | |
| runs-on: ${{ matrix.runner }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - platform: linux/amd64 | |
| runner: ubuntu-24.04 | |
| layer: base | |
| dockerfile: docker/Dockerfile | |
| tag_suffix: "" | |
| - platform: linux/amd64 | |
| runner: ubuntu-24.04 | |
| layer: huey | |
| dockerfile: docker/Dockerfile.huey | |
| tag_suffix: "huey-" | |
| - platform: linux/arm64 | |
| runner: ubuntu-24.04-arm | |
| layer: base | |
| dockerfile: docker/Dockerfile | |
| tag_suffix: "" | |
| - platform: linux/arm64 | |
| runner: ubuntu-24.04-arm | |
| layer: huey | |
| dockerfile: docker/Dockerfile.huey | |
| tag_suffix: "huey-" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| # Build and push platform-specific digest for each layer | |
| - name: Build and push by digest | |
| id: build | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ${{ matrix.dockerfile }} | |
| platforms: ${{ matrix.platform }} | |
| push: true | |
| build-args: | | |
| FULL_TAG=${{ github.ref_name }} | |
| tags: apluslms/run-gitmanager:${{ matrix.tag_suffix }}${{ github.ref_name }} | |
| outputs: type=image,name=apluslms/run-gitmanager,push-by-digest=true,name-canonical=true | |
| # Save the digest so the merge job can find it | |
| - name: Export digest | |
| run: | | |
| mkdir -p /tmp/digests | |
| digest="${{ steps.build.outputs.digest }}" | |
| touch "/tmp/digests/${digest#sha256:}" | |
| - name: Upload digest artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: digest-${{ matrix.layer }}-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }} | |
| path: /tmp/digests/* | |
| retention-days: 1 | |
| merge: | |
| name: Merge manifests | |
| runs-on: ubuntu-24.04 | |
| needs: build | |
| steps: | |
| - name: Download digests | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: /tmp/digests | |
| pattern: digest-* | |
| merge-multiple: true | |
| - name: Log in to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| # Determine tags for both base and huey images | |
| - name: Determine tags (base) | |
| id: meta_base | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: apluslms/run-gitmanager | |
| tags: | | |
| type=raw,value=latest | |
| type=match,pattern=v(\d+\.\d+)\.\d+$,group=1 | |
| - name: Determine tags (huey) | |
| id: meta_huey | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: apluslms/run-gitmanager | |
| tags: | | |
| type=raw,value=huey-latest | |
| type=match,pattern=v(\d+\.\d+)\.\d+$,group=1,prefix=huey- | |
| # Create and push multi-arch manifest for base image | |
| - name: Create and push multi-arch manifest (base) | |
| working-directory: /tmp/digests | |
| run: | | |
| docker buildx imagetools create \ | |
| $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
| $(printf 'apluslms/run-gitmanager@sha256:%s ' $(ls | grep -E 'digest-base-')) | |
| # Create and push multi-arch manifest for huey image | |
| - name: Create and push multi-arch manifest (huey) | |
| working-directory: /tmp/digests | |
| run: | | |
| docker buildx imagetools create \ | |
| $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
| $(printf 'apluslms/run-gitmanager@sha256:%s ' $(ls | grep -E 'digest-huey-')) |