2023-01-03 10:59:17 +01:00
|
|
|
#
|
|
|
|
# Build and push PostHog and PostHog Cloud container images
|
|
|
|
#
|
2023-06-07 15:05:21 +02:00
|
|
|
# - posthog_build: build and push the PostHog container image to DockerHub
|
|
|
|
#
|
|
|
|
# - posthog_cloud_build: build the PostHog Cloud container image using
|
|
|
|
# as base image the container image from the previous step. The image is
|
|
|
|
# then pushed to AWS ECR.
|
2023-01-03 10:59:17 +01:00
|
|
|
#
|
|
|
|
name: Container Images CD
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- master
|
2024-06-11 17:30:21 +02:00
|
|
|
paths-ignore:
|
|
|
|
- 'rust/**'
|
2024-06-18 17:38:53 +02:00
|
|
|
- 'livestream/**'
|
2023-07-10 18:18:09 +02:00
|
|
|
workflow_dispatch:
|
2023-01-03 10:59:17 +01:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
posthog_build:
|
|
|
|
name: Build and push PostHog
|
|
|
|
if: github.repository == 'PostHog/posthog'
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
|
|
id-token: write # allow issuing OIDC tokens for this workflow run
|
|
|
|
contents: read # allow at least reading the repo contents, add other permissions if necessary
|
|
|
|
packages: write # allow push to ghcr.io
|
|
|
|
|
|
|
|
steps:
|
2023-07-28 14:23:32 +02:00
|
|
|
- name: Check out
|
2024-11-25 09:52:08 +01:00
|
|
|
uses: actions/checkout@v4
|
2023-07-18 20:05:39 +02:00
|
|
|
with:
|
2023-07-20 14:00:00 +02:00
|
|
|
fetch-depth: 2
|
2023-01-03 10:59:17 +01:00
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
2024-11-25 09:52:08 +01:00
|
|
|
uses: docker/setup-buildx-action@v3
|
2023-01-03 10:59:17 +01:00
|
|
|
|
|
|
|
- name: Set up QEMU
|
2024-03-11 17:07:11 +01:00
|
|
|
uses: docker/setup-qemu-action@v3
|
2023-01-03 10:59:17 +01:00
|
|
|
|
|
|
|
- name: Set up Depot CLI
|
|
|
|
uses: depot/setup-action@v1
|
|
|
|
|
2023-06-21 14:49:56 +02:00
|
|
|
- name: Configure AWS credentials
|
2024-01-02 16:06:55 +01:00
|
|
|
uses: aws-actions/configure-aws-credentials@v4
|
2023-06-21 14:49:56 +02:00
|
|
|
with:
|
|
|
|
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
|
|
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
|
|
aws-region: us-east-1
|
|
|
|
|
|
|
|
- name: Login to Amazon ECR
|
|
|
|
id: aws-ecr
|
2024-01-02 16:27:40 +01:00
|
|
|
uses: aws-actions/amazon-ecr-login@v2
|
2023-06-21 14:49:56 +02:00
|
|
|
|
2024-08-12 17:23:49 +02:00
|
|
|
- name: Login to DockerHub
|
2024-10-15 04:49:56 +02:00
|
|
|
uses: docker/login-action@v3
|
2024-08-12 17:23:49 +02:00
|
|
|
with:
|
2024-10-15 04:49:56 +02:00
|
|
|
username: ${{ secrets.DOCKERHUB_USER }}
|
2024-08-12 17:23:49 +02:00
|
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
|
2023-07-18 20:05:39 +02:00
|
|
|
- name: Build and push container image
|
2023-07-10 18:45:30 +02:00
|
|
|
id: build
|
2023-01-03 10:59:17 +01:00
|
|
|
uses: depot/build-push-action@v1
|
|
|
|
with:
|
2023-06-26 11:23:07 +02:00
|
|
|
buildx-fallback: false # the fallback is so slow it's better to just fail
|
2023-01-03 10:59:17 +01:00
|
|
|
push: true
|
2023-09-21 17:50:19 +02:00
|
|
|
tags: posthog/posthog:${{ github.sha }},posthog/posthog:latest,${{ steps.aws-ecr.outputs.registry }}/posthog-cloud:master
|
2023-07-18 20:05:39 +02:00
|
|
|
platforms: linux/arm64,linux/amd64
|
2023-10-06 15:28:25 +02:00
|
|
|
build-args: COMMIT_HASH=${{ github.sha }}
|
2023-01-04 13:37:00 +01:00
|
|
|
|
2023-03-09 15:12:26 +01:00
|
|
|
- name: get deployer token
|
|
|
|
id: deployer
|
2024-03-01 16:27:42 +01:00
|
|
|
uses: getsentry/action-github-app-token@v3
|
2023-03-09 15:12:26 +01:00
|
|
|
with:
|
|
|
|
app_id: ${{ secrets.DEPLOYER_APP_ID }}
|
|
|
|
private_key: ${{ secrets.DEPLOYER_APP_PRIVATE_KEY }}
|
|
|
|
|
2024-04-09 13:13:58 +02:00
|
|
|
- name: get PR labels
|
|
|
|
id: labels
|
|
|
|
uses: ./.github/actions/get-pr-labels
|
|
|
|
with:
|
|
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
2024-02-12 19:04:07 +01:00
|
|
|
- name: Trigger PostHog Cloud deployment from Charts
|
2024-06-17 15:46:09 +02:00
|
|
|
uses: peter-evans/repository-dispatch@v3
|
2024-02-12 19:04:07 +01:00
|
|
|
with:
|
|
|
|
token: ${{ steps.deployer.outputs.token }}
|
2024-06-17 15:46:09 +02:00
|
|
|
repository: PostHog/charts
|
|
|
|
event-type: commit_state_update
|
|
|
|
client-payload: |
|
2024-02-12 19:04:07 +01:00
|
|
|
{
|
2024-06-17 15:46:09 +02:00
|
|
|
"values": {
|
|
|
|
"image": {
|
|
|
|
"sha": "${{ steps.build.outputs.digest }}"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"release": "posthog",
|
|
|
|
"commit": ${{ toJson(github.event.head_commit) }},
|
|
|
|
"repository": ${{ toJson(github.repository) }},
|
2024-08-27 23:03:01 +02:00
|
|
|
"labels": ${{ steps.labels.outputs.labels }},
|
|
|
|
"timestamp": "${{ github.event.head_commit.timestamp }}"
|
2024-02-14 09:31:45 +01:00
|
|
|
}
|
2024-02-12 19:04:07 +01:00
|
|
|
|
2023-07-18 20:05:39 +02:00
|
|
|
- name: Check for changes in plugins directory
|
|
|
|
id: check_changes_plugins
|
|
|
|
run: |
|
2024-01-16 16:16:35 +01:00
|
|
|
echo "changed=$((git diff --name-only HEAD^ HEAD | grep -q '^plugin-server/' && echo true) || echo false)" >> $GITHUB_OUTPUT
|
2023-07-18 20:05:39 +02:00
|
|
|
|
|
|
|
- name: Trigger Ingestion Cloud deployment
|
2024-01-16 16:16:35 +01:00
|
|
|
if: steps.check_changes_plugins.outputs.changed == 'true'
|
2024-06-17 12:38:31 +02:00
|
|
|
uses: peter-evans/repository-dispatch@v3
|
2023-07-18 20:05:39 +02:00
|
|
|
with:
|
|
|
|
token: ${{ steps.deployer.outputs.token }}
|
2024-06-17 12:38:31 +02:00
|
|
|
repository: PostHog/charts
|
|
|
|
event-type: commit_state_update
|
|
|
|
client-payload: |
|
2023-07-18 20:05:39 +02:00
|
|
|
{
|
2024-06-17 12:38:31 +02:00
|
|
|
"values": {
|
|
|
|
"image": {
|
|
|
|
"sha": "${{ steps.build.outputs.digest }}"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"release": "ingestion",
|
|
|
|
"commit": ${{ toJson(github.event.head_commit) }},
|
|
|
|
"repository": ${{ toJson(github.repository) }},
|
2024-08-27 23:03:01 +02:00
|
|
|
"labels": ${{ toJson(steps.labels.outputs.labels) }},
|
|
|
|
"timestamp": "${{ github.event.head_commit.timestamp }}"
|
2023-07-18 20:05:39 +02:00
|
|
|
}
|
2023-10-16 11:28:41 +02:00
|
|
|
|
2023-11-29 15:32:38 +01:00
|
|
|
- name: Check for changes that affect batch exports temporal worker
|
|
|
|
id: check_changes_batch_exports_temporal_worker
|
2023-10-16 11:28:41 +02:00
|
|
|
run: |
|
2024-09-10 10:29:20 +02:00
|
|
|
echo "changed=$((git diff --name-only HEAD^ HEAD | grep -qE '^posthog/temporal/common|^posthog/temporal/batch_exports|^posthog/batch_exports/|^posthog/management/commands/start_temporal_worker.py$|^requirements.txt$' && echo true) || echo false)" >> $GITHUB_OUTPUT
|
2023-10-16 11:28:41 +02:00
|
|
|
|
2024-11-20 19:18:10 +01:00
|
|
|
- name: Trigger Batch Exports Sync Temporal Worker Cloud deployment
|
2024-01-16 16:16:35 +01:00
|
|
|
if: steps.check_changes_batch_exports_temporal_worker.outputs.changed == 'true'
|
2024-06-11 17:30:21 +02:00
|
|
|
uses: peter-evans/repository-dispatch@v3
|
2023-10-16 11:28:41 +02:00
|
|
|
with:
|
|
|
|
token: ${{ steps.deployer.outputs.token }}
|
2024-06-11 17:30:21 +02:00
|
|
|
repository: PostHog/charts
|
|
|
|
event-type: commit_state_update
|
|
|
|
client-payload: |
|
2023-10-16 11:28:41 +02:00
|
|
|
{
|
2024-06-11 17:30:21 +02:00
|
|
|
"values": {
|
|
|
|
"image": {
|
|
|
|
"sha": "${{ steps.build.outputs.digest }}"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"release": "temporal-worker",
|
|
|
|
"commit": ${{ toJson(github.event.head_commit) }},
|
|
|
|
"repository": ${{ toJson(github.repository) }},
|
2024-08-27 23:03:01 +02:00
|
|
|
"labels": ${{ steps.labels.outputs.labels }},
|
|
|
|
"timestamp": "${{ github.event.head_commit.timestamp }}"
|
2024-11-20 19:18:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
- name: Trigger Batch Exports Temporal Worker Cloud deployment
|
|
|
|
if: steps.check_changes_batch_exports_temporal_worker.outputs.changed == 'true'
|
|
|
|
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": "${{ steps.build.outputs.digest }}"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"release": "temporal-worker-batch-exports",
|
|
|
|
"commit": ${{ toJson(github.event.head_commit) }},
|
|
|
|
"repository": ${{ toJson(github.repository) }},
|
|
|
|
"labels": ${{ steps.labels.outputs.labels }},
|
|
|
|
"timestamp": "${{ github.event.head_commit.timestamp }}"
|
2023-10-16 11:28:41 +02:00
|
|
|
}
|
2023-11-29 20:05:24 +01:00
|
|
|
|
2024-05-22 10:24:57 +02:00
|
|
|
- name: Check for changes that affect general purpose temporal worker
|
|
|
|
id: check_changes_general_purpose_temporal_worker
|
|
|
|
run: |
|
2024-09-10 10:29:20 +02:00
|
|
|
echo "changed=$((git diff --name-only HEAD^ HEAD | grep -qE '^posthog/temporal/common|^posthog/temporal/proxy_service|^posthog/management/commands/start_temporal_worker.py$|^requirements.txt$' && echo true) || echo false)" >> $GITHUB_OUTPUT
|
2024-05-22 10:24:57 +02:00
|
|
|
|
|
|
|
- name: Trigger General Purpose Temporal Worker Cloud deployment
|
|
|
|
if: steps.check_changes_general_purpose_temporal_worker.outputs.changed == 'true'
|
2024-06-11 17:30:21 +02:00
|
|
|
uses: peter-evans/repository-dispatch@v3
|
2024-05-22 10:24:57 +02:00
|
|
|
with:
|
|
|
|
token: ${{ steps.deployer.outputs.token }}
|
2024-06-11 17:30:21 +02:00
|
|
|
repository: PostHog/charts
|
|
|
|
event-type: commit_state_update
|
|
|
|
client-payload: |
|
2024-05-22 10:24:57 +02:00
|
|
|
{
|
2024-06-11 17:30:21 +02:00
|
|
|
"values": {
|
|
|
|
"image": {
|
|
|
|
"sha": "${{ steps.build.outputs.digest }}"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"release": "temporal-worker-general-purpose",
|
|
|
|
"commit": ${{ toJson(github.event.head_commit) }},
|
|
|
|
"repository": ${{ toJson(github.repository) }},
|
2024-08-27 23:03:01 +02:00
|
|
|
"labels": ${{ steps.labels.outputs.labels }},
|
|
|
|
"timestamp": "${{ github.event.head_commit.timestamp }}"
|
2024-05-22 10:24:57 +02:00
|
|
|
}
|
|
|
|
|
2023-11-29 20:05:24 +01:00
|
|
|
- name: Check for changes that affect data warehouse temporal worker
|
|
|
|
id: check_changes_data_warehouse_temporal_worker
|
|
|
|
run: |
|
2024-09-10 10:29:20 +02:00
|
|
|
echo "changed=$((git diff --name-only HEAD^ HEAD | grep -qE '^posthog/temporal/common|^posthog/temporal/data_imports|^posthog/warehouse/|^posthog/management/commands/start_temporal_worker.py$|^requirements.txt$' && echo true) || echo false)" >> $GITHUB_OUTPUT
|
2023-11-29 20:05:24 +01:00
|
|
|
|
|
|
|
- name: Trigger Data Warehouse Temporal Worker Cloud deployment
|
2024-01-16 16:16:35 +01:00
|
|
|
if: steps.check_changes_data_warehouse_temporal_worker.outputs.changed == 'true'
|
2024-06-11 17:30:21 +02:00
|
|
|
uses: peter-evans/repository-dispatch@v3
|
2023-11-29 20:05:24 +01:00
|
|
|
with:
|
|
|
|
token: ${{ steps.deployer.outputs.token }}
|
2024-06-11 17:30:21 +02:00
|
|
|
repository: PostHog/charts
|
|
|
|
event-type: commit_state_update
|
|
|
|
client-payload: |
|
2023-11-29 20:05:24 +01:00
|
|
|
{
|
2024-06-11 17:30:21 +02:00
|
|
|
"values": {
|
|
|
|
"image": {
|
|
|
|
"sha": "${{ steps.build.outputs.digest }}"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"release": "temporal-worker-data-warehouse",
|
|
|
|
"commit": ${{ toJson(github.event.head_commit) }},
|
|
|
|
"repository": ${{ toJson(github.repository) }},
|
2024-08-27 23:03:01 +02:00
|
|
|
"labels": ${{ steps.labels.outputs.labels }},
|
|
|
|
"timestamp": "${{ github.event.head_commit.timestamp }}"
|
2023-11-29 20:05:24 +01:00
|
|
|
}
|