diff --git a/.github/workflows/docker-heartbeats-processor.yaml b/.github/workflows/docker-heartbeats-processor.yaml new file mode 100644 index 0000000000..94e22d83bd --- /dev/null +++ b/.github/workflows/docker-heartbeats-processor.yaml @@ -0,0 +1,105 @@ +name: Heartbeats Processor Docker Build +on: + workflow_dispatch: + inputs: + version: + description: 'Version tag for the image' + required: true + type: string + +env: + REGISTRY_IMAGE: openmina/heartbeats-processor + +jobs: + build-heartbeat-processor-image: + strategy: + matrix: + arch: + - platform: linux/amd64 + runs-on: ubuntu-latest + - platform: linux/arm64 + runs-on: ubuntu-arm64 + runs-on: ${{ matrix.arch.runs-on }} + steps: + - name: Prepare + run: | + platform=${{ matrix.arch.platform }} + echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV + + - name: Git checkout + uses: actions/checkout@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push by digest + id: build + uses: docker/build-push-action@v6 + with: + context: . + file: ./tools/heartbeats-processor/Dockerfile + platforms: ${{ matrix.arch.platform }} + cache-from: type=gha + cache-to: type=gha,mode=max + outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true + + - name: Export digest + run: | + mkdir -p /tmp/digests + digest="${{ steps.build.outputs.digest }}" + touch "/tmp/digests/${digest#sha256:}" + + - name: Upload digest + uses: actions/upload-artifact@v4 + with: + name: heartbeat-processor-digests-${{ env.PLATFORM_PAIR }} + path: /tmp/digests/* + if-no-files-found: error + retention-days: 1 + + merge-heartbeat-processor-image: + runs-on: ubuntu-latest + needs: + - build-heartbeat-processor-image + steps: + - name: Download digests + uses: actions/download-artifact@v4 + with: + path: /tmp/digests + pattern: heartbeat-processor-digests-* + merge-multiple: true + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY_IMAGE }} + tags: | + type=sha,format=short + type=raw,value=${{ inputs.version }},enable=${{ inputs.version != '' }} + type=raw,value=v${{ inputs.version }},enable=${{ inputs.version != '' }} + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Create manifest list and push + working-directory: /tmp/digests + run: | + docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ + $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) + + - name: Inspect image + run: | + docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}