Merge pull request #713 from 0xMimir/feat/rpc-port #511
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Openmina Docker Build | |
| on: | |
| workflow_dispatch: {} | |
| push: | |
| branches: [ main, develop ] | |
| tags: [ "*" ] | |
| paths-ignore: | |
| # - ".github/**" | |
| - ".drone.yml" | |
| - "helm/**" | |
| - "*.md" | |
| - "docs/**" | |
| env: | |
| REGISTRY_NODE_IMAGE: openmina/openmina | |
| REGISTRY_FRONTEND_IMAGE: openmina/frontend | |
| jobs: | |
| build-openmina-node-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: . | |
| platforms: ${{ matrix.arch.platform }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| outputs: type=image,name=${{ env.REGISTRY_NODE_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: node-digests-${{ env.PLATFORM_PAIR }} | |
| path: /tmp/digests/* | |
| if-no-files-found: error | |
| retention-days: 1 | |
| merge-openmina-node-image: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - build-openmina-node-image | |
| steps: | |
| - name: Download digests | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: /tmp/digests | |
| pattern: node-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_NODE_IMAGE }} | |
| # generate Docker tags based on the following events/attributes | |
| tags: | | |
| type=ref,event=branch | |
| type=sha,format=short | |
| type=semver,pattern={{version}},event=tag | |
| type=ref,event=tag | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| - 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_NODE_IMAGE }}@sha256:%s ' *) | |
| - name: Inspect image | |
| run: | | |
| docker buildx imagetools inspect ${{ env.REGISTRY_NODE_IMAGE }}:${{ steps.meta.outputs.version }} | |
| # Frontend | |
| build-openmina-frontend-image: | |
| strategy: | |
| matrix: | |
| arch: | |
| - platform: linux/amd64 | |
| runs-on: ubuntu-latest | |
| - platform: linux/arm64 | |
| runs-on: ubuntu-arm64 | |
| configuration: | |
| - build_configuration: compose | |
| - build_configuration: staging | |
| 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: ./frontend | |
| platforms: ${{ matrix.arch.platform }} | |
| build-args: | | |
| BUILD_CONFIGURATION=${{ matrix.configuration.build_configuration }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| outputs: type=image,name=${{ env.REGISTRY_FRONTEND_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: frontend-${{ matrix.configuration.build_configuration }}-digests-${{ env.PLATFORM_PAIR }} | |
| path: /tmp/digests/* | |
| if-no-files-found: error | |
| retention-days: 1 | |
| merge-openmina-frontend-image: | |
| strategy: | |
| matrix: | |
| configuration: | |
| - build_configuration: compose | |
| tag_suffix: "" | |
| - build_configuration: staging | |
| tag_suffix: "" | |
| runs-on: ubuntu-latest | |
| needs: | |
| - build-openmina-frontend-image | |
| steps: | |
| - name: 📥 Checkout | |
| uses: actions/checkout@v3 | |
| - name: 🅰️ Get on-chain-voting web version from package.json | |
| id: ocv-web | |
| uses: martinbeentjes/[email protected] | |
| with: | |
| path: frontend | |
| - name: 🏷️ Conditionally Set Tag | |
| id: set_tag | |
| run: | | |
| if [[ "${{ matrix.configuration.build_configuration }}" == "staging" ]]; then | |
| echo "FINAL_TAG=staging-${{ steps.ocv-web.outputs.current-version }}" >> $GITHUB_ENV | |
| else | |
| echo "FINAL_TAG=${{ steps.meta.outputs.version }}" >> $GITHUB_ENV | |
| fi | |
| - name: Download digests | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: /tmp/digests | |
| pattern: frontend-${{ matrix.configuration.build_configuration }}-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_FRONTEND_IMAGE }} | |
| flavor: | | |
| suffix=${{ matrix.configuration.tag_suffix }} | |
| # generate Docker tags based on the following events/attributes | |
| tags: | | |
| type=ref,event=branch | |
| type=sha,format=short | |
| type=semver,pattern={{version}},event=tag | |
| type=ref,event=tag | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| type=raw,value=${{ env.FINAL_TAG }} | |
| type=raw,value=latest,enable=${{ matrix.configuration.build_configuration == 'compose' }} | |
| - 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_FRONTEND_IMAGE }}@sha256:%s ' *) \ | |
| - name: Determine tag to use | |
| id: get-tag | |
| run: | | |
| if [ -n "${{ env.FINAL_TAG }}" ]; then | |
| echo "INSPECT_TAG=${{ env.FINAL_TAG }}" >> $GITHUB_OUTPUT | |
| else | |
| echo "INSPECT_TAG=${{ steps.meta.outputs.version }}" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Inspect image | |
| run: | | |
| docker buildx imagetools inspect ${{ env.REGISTRY_FRONTEND_IMAGE }}:${{ steps.get-tag.outputs.INSPECT_TAG }} |