|
5 | 5 | branches:
|
6 | 6 | - master
|
7 | 7 |
|
| 8 | +env: |
| 9 | + REGISTRY_IMAGE: neptyne/neptyne |
| 10 | + |
8 | 11 | jobs:
|
9 |
| - docker: |
| 12 | + build: |
10 | 13 | runs-on: ubuntu-latest
|
| 14 | + strategy: |
| 15 | + fail-fast: false |
| 16 | + matrix: |
| 17 | + platform: |
| 18 | + - linux/amd64 |
| 19 | + - linux/arm64 |
11 | 20 | steps:
|
12 |
| - - |
13 |
| - name: Set up QEMU |
| 21 | + - name: Prepare |
| 22 | + run: | |
| 23 | + platform=${{ matrix.platform }} |
| 24 | + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV |
| 25 | +
|
| 26 | + - name: Docker meta |
| 27 | + id: meta |
| 28 | + uses: docker/metadata-action@v5 |
| 29 | + with: |
| 30 | + images: ${{ env.REGISTRY_IMAGE }} |
| 31 | + |
| 32 | + - name: Set up QEMU |
14 | 33 | uses: docker/setup-qemu-action@v3
|
15 |
| - - |
16 |
| - name: Set up Docker Buildx |
| 34 | + |
| 35 | + - name: Set up Docker Buildx |
17 | 36 | uses: docker/setup-buildx-action@v3
|
18 |
| - - |
19 |
| - name: Login to Docker Hub |
| 37 | + |
| 38 | + - name: Login to Docker Hub |
20 | 39 | uses: docker/login-action@v3
|
21 | 40 | with:
|
22 | 41 | username: ${{ secrets.DOCKERHUB_USERNAME }}
|
23 | 42 | password: ${{ secrets.DOCKERHUB_TOKEN }}
|
24 |
| - - |
25 |
| - name: Build and push |
| 43 | + |
| 44 | + - name: Build and push by digest |
| 45 | + id: build |
26 | 46 | uses: docker/build-push-action@v6
|
27 | 47 | with:
|
28 |
| - push: true |
29 |
| - tags: neptyne/neptyne:latest |
| 48 | + platforms: ${{ matrix.platform }} |
| 49 | + labels: ${{ steps.meta.outputs.labels }} |
| 50 | + outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true |
| 51 | + |
| 52 | + - name: Export digest |
| 53 | + run: | |
| 54 | + mkdir -p /tmp/digests |
| 55 | + digest="${{ steps.build.outputs.digest }}" |
| 56 | + touch "/tmp/digests/${digest#sha256:}" |
| 57 | +
|
| 58 | + - name: Upload digest |
| 59 | + uses: actions/upload-artifact@v4 |
| 60 | + with: |
| 61 | + name: digests-${{ env.PLATFORM_PAIR }} |
| 62 | + path: /tmp/digests/* |
| 63 | + if-no-files-found: error |
| 64 | + retention-days: 1 |
| 65 | + |
| 66 | + merge: |
| 67 | + runs-on: ubuntu-latest |
| 68 | + needs: |
| 69 | + - build |
| 70 | + steps: |
| 71 | + - name: Download digests |
| 72 | + uses: actions/download-artifact@v4 |
| 73 | + with: |
| 74 | + path: /tmp/digests |
| 75 | + pattern: digests-* |
| 76 | + merge-multiple: true |
| 77 | + |
| 78 | + - name: Set up Docker Buildx |
| 79 | + uses: docker/setup-buildx-action@v3 |
| 80 | + |
| 81 | + - name: Docker meta |
| 82 | + id: meta |
| 83 | + uses: docker/metadata-action@v5 |
| 84 | + with: |
| 85 | + images: ${{ env.REGISTRY_IMAGE }} |
| 86 | + |
| 87 | + - name: Login to Docker Hub |
| 88 | + uses: docker/login-action@v3 |
| 89 | + with: |
| 90 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 91 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 92 | + |
| 93 | + - name: Create manifest list and push |
| 94 | + working-directory: /tmp/digests |
| 95 | + run: | |
| 96 | + docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ |
| 97 | + $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) |
| 98 | +
|
| 99 | + - name: Inspect image |
| 100 | + run: | |
| 101 | + docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} |
0 commit comments