Skip to content

Commit

Permalink
feat: add continuous deployment to rust service (#24963)
Browse files Browse the repository at this point in the history
  • Loading branch information
frankh authored Sep 16, 2024
1 parent ab8186a commit ae8c37f
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 99 deletions.
80 changes: 62 additions & 18 deletions .github/workflows/rust-docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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 }}
Expand All @@ -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
Expand All @@ -111,20 +159,16 @@ 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 }}
repository: PostHog/charts
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": [],
Expand Down
81 changes: 0 additions & 81 deletions .github/workflows/rust-hook-migrator-docker.yml

This file was deleted.

0 comments on commit ae8c37f

Please sign in to comment.