|
| 1 | +name: Publish Sandbox Docker Image |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'sandbox-v\d+\.\d+\.\d+*' # Matches sandbox specific semver tags in the format of sandbox-v1.2.3, sandbox-v1.2.3-beta.1, etc. |
| 7 | + |
| 8 | +env: |
| 9 | + IMAGE_NAME: ghcr.io/usherlabs/fiet-sandbox/cex-broker |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + packages: write |
| 14 | + |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + name: Build (${{ matrix.arch }}) |
| 18 | + runs-on: ${{ matrix.runner }} |
| 19 | + strategy: |
| 20 | + matrix: |
| 21 | + include: |
| 22 | + - arch: amd64 |
| 23 | + runner: ubuntu-latest |
| 24 | + - arch: arm64 |
| 25 | + runner: [self-hosted, linux, arm64] |
| 26 | + steps: |
| 27 | + - name: Checkout repository |
| 28 | + uses: actions/checkout@v4 |
| 29 | + |
| 30 | + - name: Set up Docker Buildx |
| 31 | + uses: docker/setup-buildx-action@v3 |
| 32 | + |
| 33 | + - name: Log in to GitHub Container Registry |
| 34 | + uses: docker/login-action@v3 |
| 35 | + with: |
| 36 | + registry: ghcr.io |
| 37 | + username: ${{ github.actor }} |
| 38 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 39 | + |
| 40 | + - name: Extract metadata |
| 41 | + id: meta |
| 42 | + uses: docker/metadata-action@v5 |
| 43 | + with: |
| 44 | + images: ${{ env.IMAGE_NAME }} |
| 45 | + tags: | |
| 46 | + type=match,pattern=sandbox-v(\d+\.\d+\.\d+.*),group=1 |
| 47 | +
|
| 48 | + - name: Build and push Docker image |
| 49 | + uses: docker/build-push-action@v6 |
| 50 | + with: |
| 51 | + context: . |
| 52 | + file: ./.sandbox/Dockerfile |
| 53 | + platforms: linux/${{ matrix.arch }} |
| 54 | + push: true |
| 55 | + tags: | |
| 56 | + ${{ env.IMAGE_NAME }}:${{ fromJSON(steps.meta.outputs.json).tag-names[0] }}-${{ matrix.arch }} |
| 57 | + ${{ env.IMAGE_NAME }}:latest-${{ matrix.arch }} |
| 58 | + cache-from: type=gha,scope=${{ matrix.arch }} |
| 59 | + cache-to: type=gha,mode=max,scope=${{ matrix.arch }} |
| 60 | + |
| 61 | + manifest: |
| 62 | + name: Publish multi-arch manifest |
| 63 | + runs-on: ubuntu-latest |
| 64 | + needs: build |
| 65 | + steps: |
| 66 | + - name: Log in to GitHub Container Registry |
| 67 | + uses: docker/login-action@v3 |
| 68 | + with: |
| 69 | + registry: ghcr.io |
| 70 | + username: ${{ github.actor }} |
| 71 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 72 | + |
| 73 | + - name: Set up Docker Buildx |
| 74 | + uses: docker/setup-buildx-action@v3 |
| 75 | + |
| 76 | + - name: Extract metadata |
| 77 | + id: meta |
| 78 | + uses: docker/metadata-action@v5 |
| 79 | + with: |
| 80 | + images: ${{ env.IMAGE_NAME }} |
| 81 | + tags: | |
| 82 | + type=match,pattern=sandbox-v(\d+\.\d+\.\d+.*),group=1 |
| 83 | +
|
| 84 | + - name: Create and push manifest |
| 85 | + run: | |
| 86 | + docker buildx imagetools create \ |
| 87 | + --tag "${{ env.IMAGE_NAME }}:${{ fromJSON(steps.meta.outputs.json).tag-names[0] }}" \ |
| 88 | + --tag "${{ env.IMAGE_NAME }}:latest" \ |
| 89 | + "${{ env.IMAGE_NAME }}:${{ fromJSON(steps.meta.outputs.json).tag-names[0] }}-amd64" \ |
| 90 | + "${{ env.IMAGE_NAME }}:${{ fromJSON(steps.meta.outputs.json).tag-names[0] }}-arm64" |
| 91 | +
|
| 92 | + docker buildx imagetools inspect "${{ env.IMAGE_NAME }}:${{ fromJSON(steps.meta.outputs.json).tag-names[0] }}" |
| 93 | + docker buildx imagetools inspect "${{ env.IMAGE_NAME }}:latest" |
0 commit comments