docs: update shapes guide with subqueries, progressive loading, and T… #121
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: Publish Electric images to Docker Hub | |
| # If you decide to modify the list of triggers for this action, don't forget to also update the | |
| # conditional logic in the derive_build_vars job below. | |
| on: | |
| push: | |
| branches: ['main'] | |
| release: | |
| types: [released] | |
| # Allows the workflow to be called by the Changesets workflow | |
| workflow_call: | |
| inputs: | |
| release_tag: | |
| description: 'The @core/sync-service@... tag passed from caller' | |
| required: true | |
| type: string | |
| # Allows the workflow to be triggered manually from the UI | |
| workflow_dispatch: | |
| inputs: | |
| release_tag: | |
| description: 'The @core/sync-service@... tag to run the workflow for (e.g. @core/sync-service@1.2.10)' | |
| required: true | |
| type: string | |
| env: | |
| DOCKERHUB_REPO: electricsql/electric | |
| DOCKERHUB_CANARY_REPO: electricsql/electric-canary | |
| jobs: | |
| derive_build_vars: | |
| name: Derive build variables from the source code | |
| runs-on: blacksmith-2vcpu-ubuntu-2404 | |
| outputs: | |
| git_ref: ${{ steps.git_ref.outputs.git_ref }} | |
| is_release: ${{ steps.git_ref.outputs.is_release }} | |
| short_commit_sha: ${{ steps.vars.outputs.short_commit_sha }} | |
| electric_version: ${{ steps.vars.outputs.electric_version }} | |
| steps: | |
| - name: Determine the ref to check out | |
| id: git_ref | |
| env: | |
| INPUT_RELEASE_TAG: ${{ inputs.release_tag }} | |
| EVENT_RELEASE_TAG: ${{ github.event.release.tag_name }} | |
| COMMIT_SHA: ${{ github.sha }} | |
| run: | | |
| if [ -n "$INPUT_RELEASE_TAG" ]; then | |
| ref="refs/tags/$INPUT_RELEASE_TAG" | |
| is_release=true | |
| elif [ -n "$EVENT_RELEASE_TAG" ]; then | |
| ref="refs/tags/$EVENT_RELEASE_TAG" | |
| is_release=true | |
| else | |
| ref="$COMMIT_SHA" | |
| is_release=false | |
| fi | |
| echo "git_ref=$ref" >> $GITHUB_OUTPUT | |
| echo "is_release=$is_release" >> $GITHUB_OUTPUT | |
| - uses: actions/checkout@v4 | |
| with: | |
| # The checked out commit influences the value of the ELECTRIC_VERSION variable | |
| # that is baked into the Docker image. | |
| # | |
| # For regular pushes to main, we check out the HEAD commit and publish canary images. | |
| # | |
| # For releases we check out the tag corresponding to the release, e.g. | |
| # @core/sync-service@v1.2.10. | |
| # | |
| # For manual triggers via workflow_dispatch, we check out the tag specified manually | |
| # by the actor. | |
| ref: ${{ steps.git_ref.outputs.git_ref }} | |
| # Also important to fetch the whole history since otherwise we won't get that tags | |
| # that are required to determine the correct ELECTRIC_VERSION. | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - name: Determine short_commit_sha and electric_version to use in the build step | |
| id: vars | |
| run: | | |
| echo "short_commit_sha=$( | |
| git rev-parse --short HEAD | |
| )" >> $GITHUB_OUTPUT | |
| echo "electric_version=$( | |
| git describe --abbrev=7 --tags --always --first-parent --match '@core/sync-service@*' | sed -En 's|^@core/sync-service@||p' | |
| )" >> $GITHUB_OUTPUT | |
| build_and_push_image: | |
| strategy: | |
| matrix: | |
| include: | |
| - platform: linux/amd64 | |
| platform_id: amd64 | |
| runner: blacksmith-4vcpu-ubuntu-2404 | |
| - platform: linux/arm64/v8 | |
| platform_id: arm64 | |
| runner: blacksmith-4vcpu-ubuntu-2404-arm | |
| runs-on: ${{ matrix.runner }} | |
| needs: [derive_build_vars] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ needs.derive_build_vars.outputs.git_ref }} | |
| - uses: useblacksmith/setup-docker-builder@v1 | |
| - uses: docker/login-action@v3 | |
| with: | |
| registry: docker.io | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push by digest | |
| id: build | |
| uses: useblacksmith/build-push-action@v2 | |
| with: | |
| context: packages/sync-service | |
| build-contexts: | | |
| electric-telemetry=packages/electric-telemetry | |
| build-args: | | |
| ELECTRIC_VERSION=${{ needs.derive_build_vars.outputs.electric_version }} | |
| platforms: ${{ matrix.platform }} | |
| push: true | |
| # push an untagged image and export its digest | |
| # the subsequent merge job will assemble the manifest list and apply tags | |
| outputs: type=image,push-by-digest=true,name-canonical=true,push=true | |
| tags: | | |
| ${{ env.DOCKERHUB_REPO }} | |
| ${{ env.DOCKERHUB_CANARY_REPO }} | |
| # Save the digest so the merge job can find both platform images | |
| - name: Export digest | |
| run: | | |
| mkdir -p /tmp/digests | |
| echo "${{ steps.build.outputs.digest }}" > "/tmp/digests/${{ matrix.platform_id }}.digest" | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: digests-${{ matrix.platform_id }} | |
| path: /tmp/digests/* | |
| publish_tagged_image: | |
| needs: [derive_build_vars, build_and_push_image] | |
| runs-on: blacksmith-2vcpu-ubuntu-2404 | |
| steps: | |
| - uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - uses: useblacksmith/setup-docker-builder@v1 | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| pattern: digests-* | |
| merge-multiple: true | |
| path: /tmp/digests | |
| - name: Derive image tags from the GitHub Actions event | |
| run: | | |
| if [ "${{ needs.derive_build_vars.outputs.is_release }}" = "true" ]; then | |
| # A release triggers official release image publishing | |
| echo "ELECTRIC_TAGS=-t $DOCKERHUB_REPO:latest -t $DOCKERHUB_REPO:${{ needs.derive_build_vars.outputs.electric_version }}" >> $GITHUB_ENV | |
| echo "ELECTRIC_CANARY_TAGS=" >> $GITHUB_ENV | |
| else | |
| # A regular push to the main branch triggers canary image publishing | |
| echo "ELECTRIC_TAGS=-t $DOCKERHUB_REPO:canary" >> $GITHUB_ENV | |
| echo "ELECTRIC_CANARY_TAGS=-t $DOCKERHUB_CANARY_REPO:latest -t $DOCKERHUB_CANARY_REPO:${{ needs.derive_build_vars.outputs.short_commit_sha }}" >> $GITHUB_ENV | |
| fi | |
| - name: Create multi-arch manifest list | |
| run: | | |
| set -euo pipefail | |
| # Build a list of $DOCKERHUB_REPO@sha256:... source images | |
| ELECTRIC_IMAGES=$( | |
| for f in /tmp/digests/*.digest; do | |
| echo $DOCKERHUB_REPO@$(cat $f) | |
| done | |
| ) | |
| # Create a manifest list for $DOCKERHUB_REPO:canary that includes both platforms | |
| docker buildx imagetools create $ELECTRIC_TAGS $ELECTRIC_IMAGES | |
| if [ -n "$ELECTRIC_CANARY_TAGS" ]; then | |
| # Build a list of $DOCKERHUB_CANARY_REPO@sha256:... source images | |
| ELECTRIC_CANARY_IMAGES=$( | |
| for f in /tmp/digests/*.digest; do | |
| echo $DOCKERHUB_CANARY_REPO@$(cat $f) | |
| done | |
| ) | |
| # Create a manifest list for $DOCKERHUB_CANARY_REPO:... that includes both platforms | |
| docker buildx imagetools create $ELECTRIC_CANARY_TAGS $ELECTRIC_CANARY_IMAGES | |
| fi |