|
1 | | -name: Publish Docker |
2 | | - |
| 1 | +name: Publish Docker - main |
3 | 2 | on: |
4 | 3 | push: |
5 | 4 | branches: |
6 | 5 | - main |
7 | 6 |
|
| 7 | +env: |
| 8 | + IMAGE: tecokit/edge-ml_dataset-store |
| 9 | + |
8 | 10 | jobs: |
9 | | - push_to_registry: |
10 | | - name: Push Docker image to Docker Hub |
| 11 | + build: |
| 12 | + name: Build (${{ matrix.platform }}) |
| 13 | + runs-on: ${{ matrix.runner }} |
| 14 | + strategy: |
| 15 | + fail-fast: false |
| 16 | + matrix: |
| 17 | + include: |
| 18 | + - platform: linux/amd64 |
| 19 | + runner: ubuntu-latest |
| 20 | + - platform: linux/arm64 |
| 21 | + runner: ubuntu-24.04-arm |
| 22 | + steps: |
| 23 | + - name: Prepare platform pair |
| 24 | + run: | |
| 25 | + platform=${{ matrix.platform }} |
| 26 | + echo "PLATFORM_PAIR=${platform//\//-}" >> "$GITHUB_ENV" |
| 27 | + - name: Checkout |
| 28 | + uses: actions/checkout@v4 |
| 29 | + - name: Set up Docker Buildx |
| 30 | + uses: docker/setup-buildx-action@v3 |
| 31 | + - name: Login to Docker Hub |
| 32 | + uses: docker/login-action@v3 |
| 33 | + with: |
| 34 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 35 | + password: ${{ secrets.DOCKER_PASSWORD }} |
| 36 | + - name: Build and push by digest |
| 37 | + id: build |
| 38 | + uses: docker/build-push-action@v6 |
| 39 | + with: |
| 40 | + context: . |
| 41 | + platforms: ${{ matrix.platform }} |
| 42 | + outputs: type=image,name=${{ env.IMAGE }},push-by-digest=true,name-canonical=true,push=true |
| 43 | + - name: Export digest |
| 44 | + run: | |
| 45 | + mkdir -p "${{ runner.temp }}/digests" |
| 46 | + digest="${{ steps.build.outputs.digest }}" |
| 47 | + touch "${{ runner.temp }}/digests/${digest#sha256:}" |
| 48 | + - name: Upload digest |
| 49 | + uses: actions/upload-artifact@v4 |
| 50 | + with: |
| 51 | + name: digests-${{ env.PLATFORM_PAIR }} |
| 52 | + path: ${{ runner.temp }}/digests/* |
| 53 | + if-no-files-found: error |
| 54 | + retention-days: 1 |
| 55 | + |
| 56 | + merge: |
| 57 | + name: Merge manifest and push |
11 | 58 | runs-on: ubuntu-latest |
| 59 | + needs: |
| 60 | + - build |
12 | 61 | steps: |
13 | | - - name: Check out the repo |
14 | | - uses: actions/checkout@v2 |
15 | | - - name: Push to Docker Hub |
16 | | - uses: docker/build-push-action@v1 |
| 62 | + - name: Download digests |
| 63 | + uses: actions/download-artifact@v4 |
| 64 | + with: |
| 65 | + path: ${{ runner.temp }}/digests |
| 66 | + pattern: digests-* |
| 67 | + merge-multiple: true |
| 68 | + - name: Set up Docker Buildx |
| 69 | + uses: docker/setup-buildx-action@v3 |
| 70 | + - name: Login to Docker Hub |
| 71 | + uses: docker/login-action@v3 |
17 | 72 | with: |
18 | 73 | username: ${{ secrets.DOCKER_USERNAME }} |
19 | 74 | password: ${{ secrets.DOCKER_PASSWORD }} |
20 | | - repository: tecokit/dataset-store |
21 | | - tag_with_ref: true |
| 75 | + - name: Create manifest list and push |
| 76 | + working-directory: ${{ runner.temp }}/digests |
| 77 | + run: | |
| 78 | + docker buildx imagetools create -t "${{ env.IMAGE }}:latest" \ |
| 79 | + $(printf '${{ env.IMAGE }}@sha256:%s ' *) |
| 80 | + - name: Inspect image |
| 81 | + run: | |
| 82 | + docker buildx imagetools inspect "${{ env.IMAGE }}:latest" |
0 commit comments