Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(devex): skip sandbox image builds on skills-only and fork PRs (#84063)

Julian Bezdb8a91273731
diff --git a/.github/workflows/cd-sandbox-base-image.yml b/.github/workflows/cd-sandbox-base-image.yml
index 3a7389bc200e..4f97cd5ef476 100644
--- a/.github/workflows/cd-sandbox-base-image.yml
+++ b/.github/workflows/cd-sandbox-base-image.yml
@@ -4,12 +4,16 @@ on:
push:
branches:
- master
- # paths mirror the changes job's dorny filter, which still gates push events.
+ # Narrower than the changes job's dorny filter, which also gates push events.
+ # A skills edit changes a COPY payload rather than a build instruction, so it
+ # cannot break the image build, and the :sha image a PR build pushes is never
+ # pulled by anything. `ci-agent-skills.yml` already builds the same skills on
+ # the same PR. Master keeps rebuilding on skills changes through the filter
+ # below, so the :master image production resolves still gets current skills.
pull_request:
paths:
- '.github/workflows/cd-sandbox-base-image.yml'
- 'products/tasks/backend/sandbox/images/**'
- - 'products/*/skills/**'
- 'products/posthog_ai/scripts/**'
# The notebook image bakes this package and stamps its content hash.
- 'products/notebooks/backend/sandbox/kernel/**'
@@ -20,7 +24,13 @@ jobs:
changes:
runs-on: ubuntu-24.04
timeout-minutes: 5
- if: github.repository_owner == 'PostHog'
+ # A fork PR runs in the base repo, so `repository_owner` does not exclude it,
+ # but its read-only GITHUB_TOKEN cannot push to ghcr.io. Skipping here leaves
+ # `sandbox_image` unset so both build jobs skip too, which keeps a fork off
+ # the skills build it would only pay for to fail at the push.
+ if: |
+ github.repository_owner == 'PostHog' &&
+ (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository)
name: Determine if sandbox image needs to be built
permissions:
contents: read
@@ -40,7 +50,9 @@ jobs:
id: filter
with:
token: ${{ steps.app-token.outputs.token || github.token }}
- # Keep in sync with the trigger-level pull_request paths above.
+ # Wider than the trigger-level pull_request paths above, because
+ # this also gates push events, where a skills change does have to
+ # rebuild the image that :master serves.
filters: |
sandbox_image:
- '.github/workflows/cd-sandbox-base-image.yml'
@@ -54,7 +66,8 @@ jobs:
needs: changes
name: Build agent skills from source
if: |
- github.repository_owner == 'PostHog' && (
+ github.repository_owner == 'PostHog' &&
+ (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && (
needs.changes.outputs.sandbox_image == 'true' ||
github.event_name == 'workflow_dispatch' ||
contains(github.event.pull_request.labels.*.name, 'build-tasks-sandbox-image')
@@ -168,7 +181,8 @@ jobs:
needs: [changes, build_skills]
name: Build and push Tasks Sandbox container image
if: |
- github.repository_owner == 'PostHog' && (
+ github.repository_owner == 'PostHog' &&
+ (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && (
needs.changes.outputs.sandbox_image == 'true' ||
github.event_name == 'workflow_dispatch' ||
contains(github.event.pull_request.labels.*.name, 'build-tasks-sandbox-image')