diff --git a/.github/workflows/rust-docker-build.yml b/.github/workflows/rust-docker-build.yml index a677ed818f3a5..892b492bad6bf 100644 --- a/.github/workflows/rust-docker-build.yml +++ b/.github/workflows/rust-docker-build.yml @@ -11,17 +11,26 @@ on: jobs: build: - name: Build and publish container image + name: build ${{ matrix.image }} strategy: matrix: - image: - - capture - - hook-api - - hook-janitor - - hook-worker - - cyclotron-janitor - - cyclotron-fetch - - property-defs-rs + include: + - image: capture + dockerfile: ./rust/Dockerfile + - image: hook-api + dockerfile: ./rust/Dockerfile + - image: hook-janitor + dockerfile: ./rust/Dockerfile + - image: hook-worker + dockerfile: ./rust/Dockerfile + - image: hook-migrator + dockerfile: ./rust/Dockerfile.migrate-hooks + - image: cyclotron-janitor + dockerfile: ./rust/Dockerfile + - image: cyclotron-fetch + dockerfile: ./rust/Dockerfile + - image: property-defs-rs + dockerfile: ./rust/Dockerfile runs-on: depot-ubuntu-22.04-4 permissions: id-token: write # allow issuing OIDC tokens for this workflow run @@ -30,6 +39,13 @@ jobs: outputs: capture_digest: ${{ steps.digest.outputs.capture_digest }} + cyclotron-fetch_digest: ${{ steps.digest.outputs.cyclotron-fetch_digest }} + cyclotron-janitor_digest: ${{ steps.digest.outputs.cyclotron-janitor_digest }} + property-defs-rs_digest: ${{ steps.digest.outputs.property-defs-rs_digest }} + hook-api_digest: ${{ steps.digest.outputs.hook-api_digest }} + hook-janitor_digest: ${{ steps.digest.outputs.hook-janitor_digest }} + hook-worker_digest: ${{ steps.digest.outputs.hook-worker_digest }} + hook-migrator_digest: ${{ steps.digest.outputs.hook-migrator_digest }} defaults: run: @@ -83,7 +99,7 @@ jobs: uses: depot/build-push-action@v1 with: context: ./rust/ - file: ./rust/Dockerfile + file: ${{ matrix.dockerfile }} push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} @@ -97,12 +113,44 @@ jobs: run: | echo ${{ steps.docker_build.outputs.digest }} echo "${{matrix.image}}_digest=${{ steps.docker_build.outputs.digest }}" >> $GITHUB_OUTPUT + cat $GITHUB_OUTPUT deploy: - name: Deploy capture-replay + name: deploy ${{ matrix.release }} runs-on: ubuntu-latest needs: build if: github.ref == 'refs/heads/master' + strategy: + matrix: + include: + - release: capture + values: + image: + sha: "${{ needs.build.outputs.capture_digest }}" + - release: capture-replay + values: + image: + sha: "${{ needs.build.outputs.capture_digest }}" + - release: cyclotron + values: + fetch_image: + sha: "${{ needs.build.outputs.cyclotron-fetch_digest }}" + janitor_image: + sha: "${{ needs.build.outputs.cyclotron-janitor_digest }}" + - release: property-defs-rs + values: + image: + sha: "${{ needs.build.outputs.property-defs-rs_digest }}" + - release: hoghooks + values: + api_image: + sha: "${{ needs.build.outputs.hook-api_digest }}" + janitor_image: + sha: "${{ needs.build.outputs.hook-janitor_digest }}" + worker_image: + sha: "${{ needs.build.outputs.hook-worker_digest }}" + migrator_image: + sha: "${{ needs.build.outputs.hook-migrator_digest }}" steps: - name: get deployer token id: deployer @@ -111,7 +159,7 @@ jobs: app_id: ${{ secrets.DEPLOYER_APP_ID }} private_key: ${{ secrets.DEPLOYER_APP_PRIVATE_KEY }} - - name: Trigger livestream deployment + - name: trigger ${{ matrix.release }} deployment uses: peter-evans/repository-dispatch@v3 with: token: ${{ steps.deployer.outputs.token }} @@ -119,12 +167,8 @@ jobs: event-type: commit_state_update client-payload: | { - "values": { - "image": { - "sha": "${{ needs.build.outputs.capture_digest }}" - } - }, - "release": "capture-replay", + "values": ${{ toJson(matrix.values) }}, + "release": "${{ matrix.release }}", "commit": ${{ toJson(github.event.head_commit) }}, "repository": ${{ toJson(github.repository) }}, "labels": [], diff --git a/.github/workflows/rust-hook-migrator-docker.yml b/.github/workflows/rust-hook-migrator-docker.yml deleted file mode 100644 index bc9c52a8ed339..0000000000000 --- a/.github/workflows/rust-hook-migrator-docker.yml +++ /dev/null @@ -1,81 +0,0 @@ -name: Build rust hook-migrator docker image - -on: - workflow_dispatch: - push: - paths: - - 'rust/**' - - '.github/workflows/rust-hook-migrator-docker.yml' - branches: - - 'master' - -permissions: - packages: write - -jobs: - build: - name: build and publish hook-migrator image - runs-on: depot-ubuntu-22.04-4 - permissions: - id-token: write # allow issuing OIDC tokens for this workflow run - contents: read # allow reading the repo contents - packages: write # allow push to ghcr.io - - defaults: - run: - working-directory: rust - - steps: - - name: Check Out Repo - # Checkout project code - # Use sparse checkout to only select files in rust directory - # Turning off cone mode ensures that files in the project root are not included during checkout - uses: actions/checkout@v3 - with: - sparse-checkout: 'rust/' - sparse-checkout-cone-mode: false - - - name: Set up Depot CLI - uses: depot/setup-action@v1 - - - name: Login to ghcr.io - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Docker meta - id: meta - uses: docker/metadata-action@v5 - with: - images: ghcr.io/posthog/posthog/hook-migrator - tags: | - type=ref,event=pr - type=ref,event=branch - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=sha - - - name: Set up Docker Buildx - id: buildx - uses: docker/setup-buildx-action@v2 - - - name: Build and push migrator - id: docker_build_hook_migrator - uses: depot/build-push-action@v1 - with: - context: ./rust/ - file: ./rust/Dockerfile.migrate-hooks - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - platforms: linux/arm64 - cache-from: type=gha - cache-to: type=gha,mode=max - - - name: Hook-migrator image digest - run: echo ${{ steps.docker_build_hook_migrator.outputs.digest }}