|
6 | 6 | - '*' |
7 | 7 |
|
8 | 8 | jobs: |
9 | | - build-and-push-image: |
| 9 | + build: |
10 | 10 | strategy: |
11 | 11 | matrix: |
12 | 12 | include: |
@@ -49,11 +49,68 @@ jobs: |
49 | 49 | openhv/server |
50 | 50 | ghcr.io/${{ github.repository }} |
51 | 51 |
|
52 | | - - name: Build and push Docker image |
| 52 | + - name: Build and push by digest |
| 53 | + id: build |
53 | 54 | uses: docker/build-push-action@v6 |
54 | 55 | with: |
55 | | - context: . |
56 | 56 | platforms: ${{ matrix.platform }} |
57 | | - push: true |
58 | | - tags: ${{ steps.meta.outputs.tags }} |
59 | 57 | labels: ${{ steps.meta.outputs.labels }} |
| 58 | + tags: ${{ steps.meta.outputs.tags }} |
| 59 | + outputs: type=image,push-by-digest=true,name-canonical=true,push=true |
| 60 | + |
| 61 | + - name: Export digest |
| 62 | + run: | |
| 63 | + mkdir -p ${{ runner.temp }}/digests |
| 64 | + digest="${{ steps.build.outputs.digest }}" |
| 65 | + touch "${{ runner.temp }}/digests/${digest#sha256:}" |
| 66 | +
|
| 67 | + - name: Upload digest |
| 68 | + uses: actions/upload-artifact@v4 |
| 69 | + with: |
| 70 | + name: digests-${{ env.PLATFORM_PAIR }} |
| 71 | + path: ${{ runner.temp }}/digests/* |
| 72 | + if-no-files-found: error |
| 73 | + retention-days: 1 |
| 74 | + |
| 75 | + |
| 76 | + merge: |
| 77 | + runs-on: ubuntu-latest |
| 78 | + needs: |
| 79 | + - build |
| 80 | + steps: |
| 81 | + - name: Download digests |
| 82 | + uses: actions/download-artifact@v4 |
| 83 | + with: |
| 84 | + path: ${{ runner.temp }}/digests |
| 85 | + pattern: digests-* |
| 86 | + merge-multiple: true |
| 87 | + |
| 88 | + - name: Log in to Docker Hub |
| 89 | + uses: docker/login-action@v3 |
| 90 | + with: |
| 91 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 92 | + password: ${{ secrets.DOCKER_PASSWORD }} |
| 93 | + |
| 94 | + - name: Set up Docker Buildx |
| 95 | + uses: docker/setup-buildx-action@v3 |
| 96 | + |
| 97 | + - name: Docker meta |
| 98 | + id: meta |
| 99 | + uses: docker/metadata-action@v5 |
| 100 | + with: |
| 101 | + images: ${{ env.REGISTRY_IMAGE }} |
| 102 | + tags: | |
| 103 | + type=ref,event=branch |
| 104 | + type=ref,event=pr |
| 105 | + type=semver,pattern={{version}} |
| 106 | + type=semver,pattern={{major}}.{{minor}} |
| 107 | +
|
| 108 | + - name: Create manifest list and push |
| 109 | + working-directory: ${{ runner.temp }}/digests |
| 110 | + run: | |
| 111 | + docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ |
| 112 | + $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) |
| 113 | +
|
| 114 | + - name: Inspect image |
| 115 | + run: | |
| 116 | + docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} |
0 commit comments