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