Skip to content

feat(replay-vision): API validation + lens_result row column #81036

feat(replay-vision): API validation + lens_result row column

feat(replay-vision): API validation + lens_result row column #81036

name: Build and deploy node container image
on:
workflow_dispatch:
pull_request:
merge_group:
push:
branches:
- 'master'
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
changes:
runs-on: ubuntu-24.04
permissions:
contents: read
pull-requests: read
timeout-minutes: 5
if: github.repository == 'PostHog/posthog' && github.event_name != 'merge_group'
name: Determine need to run node Docker build
outputs:
node_files: ${{ steps.filter.outputs.node_files }}
steps:
- name: Check out
uses: actions/checkout@v6
- uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
id: app-token
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
with:
client-id: ${{ secrets.GH_APP_POSTHOG_PATHS_FILTER_APP_ID }}
private-key: ${{ secrets.GH_APP_POSTHOG_PATHS_FILTER_PRIVATE_KEY }}
- uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
id: filter
with:
token: ${{ steps.app-token.outputs.token || github.token }}
filters: |
node_files:
- 'nodejs/**'
- 'common/hogvm/typescript/**'
- 'common/plugin_transpiler/**'
- 'common/esbuilder/**'
- 'common/replay-shared/**'
- 'common/replay-headless/**'
- 'rust/cyclotron-node/**'
- 'Dockerfile.node'
- '.github/workflows/ci-nodejs-container.yml'
- 'turbo.json'
- 'package.json'
- 'pnpm-lock.yaml'
- 'pnpm-workspace.yaml'
build:
needs: changes
name: Build and push node image
if: |
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && needs.changes.outputs.node_files == 'true') ||
github.event_name == 'merge_group' ||
(github.event_name == 'push' && github.ref == 'refs/heads/master' && needs.changes.outputs.node_files == 'true')
runs-on: depot-ubuntu-latest
timeout-minutes: 30
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
steps:
- name: Check out
uses: actions/checkout@v6
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
- name: Set up QEMU
uses: docker/setup-qemu-action@ce360397dd3f832beb865e1373c09c0e9f86d70a # v4.0.0
- name: Set up Depot CLI
uses: depot/setup-action@15c09a5f77a0840ad4bce955686522a257853461 # v1.7.1
- name: Docker meta and registry login
id: docker-meta
uses: ./.github/actions/docker-meta
with:
image-name: posthog-node
aws-role-to-assume: ${{ secrets.AWS_ECR_PUBLISH_IAM_ROLE }}
github-token: ${{ secrets.GITHUB_TOKEN }}
dockerhub-username: ${{ secrets.DOCKERHUB_USER }}
dockerhub-password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push container image
id: build
uses: depot/build-push-action@5f3b3c2e5a00f0093de47f657aeaefcedff27d18 # v1.17.0
with:
context: .
buildx-fallback: false
project: '00mrvlsdvh'
push: true
file: Dockerfile.node
tags: ${{ steps.docker-meta.outputs.tags }}
labels: ${{ steps.docker-meta.outputs.labels }}
platforms: linux/arm64,linux/amd64
build-args: |
COMMIT_HASH=${{ github.sha }}
- name: Container image digest
env:
IMAGE_DIGEST: ${{ steps.build.outputs.digest }}
IMAGE_REGISTRY: ${{ steps.docker-meta.outputs.ecr-registry }}
run: |
echo "Image digest: $IMAGE_DIGEST"
echo "Full image reference: $IMAGE_REGISTRY/posthog-node:${{ github.sha }}@$IMAGE_DIGEST"
echo "## Container image built :rocket:" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Image reference:** \`$IMAGE_REGISTRY/posthog-node:${{ github.sha }}@$IMAGE_DIGEST\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Image SHA:** \`${{ github.sha }}@$IMAGE_DIGEST\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- Commit: \`${{ github.sha }}\`" >> $GITHUB_STEP_SUMMARY
echo "- Digest: \`$IMAGE_DIGEST\`" >> $GITHUB_STEP_SUMMARY
- name: Report failure
if: failure()
uses: PostHog/posthog-github-action@58dea254b598fb5d469c0699c98af8288a7f7650 # v1.2.0
with:
posthog-token: ${{ secrets.POSTHOG_API_TOKEN }}
event: 'node-image-build'
properties: '{"status": "failure", "commit_hash": "${{ github.sha }}"}'
- name: Report failure to DevEx PostHog
if: failure()
continue-on-error: true
uses: PostHog/posthog-github-action@58dea254b598fb5d469c0699c98af8288a7f7650 # v1.2.0
with:
posthog-token: ${{ secrets.POSTHOG_DEVEX_PROJECT_API_TOKEN }}
event: 'node-image-build'
properties: '{"status": "failure", "commit_hash": "${{ github.sha }}"}'
- name: Get deployer token
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
id: deployer
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
with:
client-id: ${{ secrets.GH_APP_CHARTS_DEPLOYER_APP_ID }}
private-key: ${{ secrets.GH_APP_CHARTS_DEPLOYER_PRIVATE_KEY }}
owner: PostHog
repositories: charts
- name: Get PR labels
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
id: labels
uses: ./.github/actions/get-pr-labels
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Trigger node deployment
if: github.ref == 'refs/heads/master' && github.event_name == 'push'
uses: peter-evans/repository-dispatch@28959ce8df70de7be546dd1250a005dd32156697 # v4.0.1
with:
token: ${{ steps.deployer.outputs.token }}
repository: PostHog/charts
event-type: commit_state_update
client-payload: |
{
"values": {
"image": {
"sha": "${{ github.sha }}@${{ steps.build.outputs.digest }}"
}
},
"release": "node",
"commit": ${{ toJson(github.event.head_commit) }},
"repository": ${{ toJson(github.repository) }},
"labels": ${{ steps.labels.outputs.labels }},
"timestamp": "${{ github.event.head_commit.timestamp }}"
}