|
41 | 41 | required: true
|
42 | 42 |
|
43 | 43 | jobs:
|
44 |
| - publish: |
45 |
| - uses: coatl-dev/workflows/.github/workflows/docker-build-push-multi-platform.yml@v4 |
46 |
| - with: |
47 |
| - registry-image: ${{ inputs.image }} |
48 |
| - metadata-tags: | |
49 |
| - ${{ inputs.tags }} |
50 |
| - registry-username: ${{ inputs.username }} |
51 |
| - build-file: ${{ inputs.version }}/${{ inputs.variant }}/Dockerfile |
52 |
| - build-cache-key: ${{ inputs.version }}-${{ inputs.variant }} |
53 |
| - build-cache: ${{ fromJson(inputs.build-cache) }} |
54 |
| - build-digest-key: ${{ inputs.version }}-${{ inputs.variant }} |
55 |
| - secrets: |
56 |
| - registry-password: ${{ secrets.password }} |
| 44 | + build: |
| 45 | + runs-on: ${{ matrix.builder.runner-image }} |
| 46 | + strategy: |
| 47 | + fail-fast: false |
| 48 | + matrix: |
| 49 | + builder: |
| 50 | + - runner-image: ubuntu-24.04 |
| 51 | + platform: linux/amd64 |
| 52 | + - runner-image: blacksmith-arm |
| 53 | + platform: linux/arm64 |
| 54 | + steps: |
| 55 | + - name: Prepare |
| 56 | + run: | |
| 57 | + platform=${{ matrix.builder.platform }} |
| 58 | + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV |
| 59 | +
|
| 60 | + - name: Docker meta |
| 61 | + id: meta |
| 62 | + uses: docker/metadata-action@v5 |
| 63 | + with: |
| 64 | + images: | |
| 65 | + ${{ inputs.image }} |
| 66 | +
|
| 67 | + - name: Set up Docker Buildx |
| 68 | + uses: docker/setup-buildx-action@v3 |
| 69 | + |
| 70 | + - name: Login to Docker registry |
| 71 | + uses: docker/login-action@v3 |
| 72 | + with: |
| 73 | + username: ${{ inputs.username }} |
| 74 | + password: ${{ secrets.password }} |
| 75 | + |
| 76 | + - name: Build and push by digest |
| 77 | + id: build |
| 78 | + uses: docker/build-push-action@v6 |
| 79 | + with: |
| 80 | + cache-from: type=gha,scope=${{ inputs.version }}-${{ inputs.variant }}-${{ env.PLATFORM_PAIR }} |
| 81 | + cache-to: type=gha,scope=${{ inputs.version }}-${{ inputs.variant }}-${{ env.PLATFORM_PAIR }},mode=max |
| 82 | + file: ${{ inputs.version }}/${{ inputs.variant }}/Dockerfile |
| 83 | + labels: ${{ steps.meta.outputs.labels }} |
| 84 | + no-cache: ${{ ! inputs.build-cache }} |
| 85 | + outputs: type=image,name=${{ inputs.image }},push-by-digest=true,name-canonical=true,push=true |
| 86 | + platforms: ${{ matrix.builder.platform }} |
| 87 | + |
| 88 | + - name: Export digest |
| 89 | + run: | |
| 90 | + mkdir -p ${{ runner.temp }}/digests |
| 91 | + digest="${{ steps.build.outputs.digest }}" |
| 92 | + touch "${{ runner.temp }}/digests/${digest#sha256:}" |
| 93 | +
|
| 94 | + - name: Upload digest |
| 95 | + uses: actions/upload-artifact@v4 |
| 96 | + with: |
| 97 | + name: digests-${{ inputs.version }}-${{ inputs.variant }}-${{ env.PLATFORM_PAIR }} |
| 98 | + path: ${{ runner.temp }}/digests/* |
| 99 | + if-no-files-found: error |
| 100 | + retention-days: 1 |
| 101 | + |
| 102 | + merge: |
| 103 | + runs-on: ubuntu-latest |
| 104 | + needs: |
| 105 | + - build |
| 106 | + steps: |
| 107 | + - name: Download digests |
| 108 | + uses: actions/download-artifact@v4 |
| 109 | + with: |
| 110 | + path: ${{ runner.temp }}/digests |
| 111 | + pattern: digests-${{ inputs.version }}-${{ inputs.variant }}-* |
| 112 | + merge-multiple: true |
| 113 | + |
| 114 | + - name: Set up Docker Buildx |
| 115 | + uses: docker/setup-buildx-action@v3 |
| 116 | + |
| 117 | + - name: Docker meta |
| 118 | + id: meta |
| 119 | + uses: docker/metadata-action@v5 |
| 120 | + with: |
| 121 | + images: | |
| 122 | + ${{ inputs.image }} |
| 123 | + tags: | |
| 124 | + ${{ inputs.tags }} |
| 125 | +
|
| 126 | + - name: Login to Docker registry |
| 127 | + uses: docker/login-action@v3 |
| 128 | + with: |
| 129 | + username: ${{ inputs.username }} |
| 130 | + password: ${{ secrets.password }} |
| 131 | + |
| 132 | + - name: Create manifest list and push |
| 133 | + working-directory: ${{ runner.temp }}/digests |
| 134 | + run: | |
| 135 | + docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ |
| 136 | + $(printf '${{ inputs.image }}@sha256:%s ' *) |
| 137 | +
|
| 138 | + - name: Inspect image |
| 139 | + run: | |
| 140 | + docker buildx imagetools inspect ${{ inputs.image }}:${{ steps.meta.outputs.version }} |
0 commit comments