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