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