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(ci): scope workflow secrets to the jobs that use them (#67145)

Tom Piccirellocf78d9559cf4
diff --git a/.depot/workflows/ci-backend.yml b/.depot/workflows/ci-backend.yml
index e49d1f6f43e3..15f917536492 100644
--- a/.depot/workflows/ci-backend.yml
+++ b/.depot/workflows/ci-backend.yml
@@ -22,7 +22,9 @@
# - Three data-modeling tests deselected (Depot-only MinIO 403 quarantine)
# - GITHUB_TOKEN / OTEL_SERVICE_NAME neutralized (ambient on Depot, not on GHA)
# - Docker Hub login reads Depot's secret store (secrets.DOCKERHUB_*) rather than
-# canonical's env.DOCKERHUB_USERNAME / vars.DOCKERHUB_USER
+# canonical's env.DOCKERHUB_USERNAME / vars.DOCKERHUB_USER — depot never indirects
+# through env:, so canonical's per-job env-scoping (workflow-level -> job-level,
+# for the gha-workflow-env-secret Semgrep fix) is depot-exempt
# - Service launch via `nohup ... --down` (survives Depot's step-shell teardown) and
# waits on a superset (objectstorage, Temporal) with an explicit 900s timeout
# - Path-filter persons-SQL folded into migrations. check-migrations.if also gates
diff --git a/.github/workflows/_rust-build-images.yml b/.github/workflows/_rust-build-images.yml
index 5884e3430013..7a346c369def 100644
--- a/.github/workflows/_rust-build-images.yml
+++ b/.github/workflows/_rust-build-images.yml
@@ -36,6 +36,11 @@ on:
description: 'Whether to push built images to the registry'
type: boolean
default: true
+ secrets:
+ POSTHOG_API_TOKEN:
+ required: false
+ POSTHOG_DEVEX_PROJECT_API_TOKEN:
+ required: false
outputs:
digests:
description: 'JSON object mapping image name to digest'
diff --git a/.github/workflows/call-flags-project-board.yml b/.github/workflows/call-flags-project-board.yml
index 50e7b2891e5b..13a4b0df42e8 100644
--- a/.github/workflows/call-flags-project-board.yml
+++ b/.github/workflows/call-flags-project-board.yml
@@ -18,4 +18,8 @@ jobs:
pr_number: ${{ github.event.pull_request.number }}
pr_node_id: ${{ github.event.pull_request.node_id }}
is_draft: ${{ github.event.pull_request.draft }}
+ # The called workflow lives in PostHog/.github and only declares `inputs:` (no `secrets:`) under
+ # workflow_call, so scoped secret passing isn't possible until that reusable workflow adds a
+ # secrets: block too.
+ # nosemgrep: yaml.github-actions.security.secrets-inherit.secrets-inherit
secrets: inherit
diff --git a/.github/workflows/ci-actionlint.yml b/.github/workflows/ci-actionlint.yml
index c4355c1a4e4b..a8aab9e4652e 100644
--- a/.github/workflows/ci-actionlint.yml
+++ b/.github/workflows/ci-actionlint.yml
@@ -32,8 +32,9 @@ jobs:
run: |
set -euo pipefail
mkdir -p ./.bin
- curl -fsSL "https://raw.githubusercontent.com/rhysd/actionlint/${ACTIONLINT_SCRIPT_REF}/scripts/download-actionlint.bash" \
- | bash -s -- "${ACTIONLINT_VERSION}" ./.bin
+ curl -fsSL -o ./download-actionlint.bash \
+ "https://raw.githubusercontent.com/rhysd/actionlint/${ACTIONLINT_SCRIPT_REF}/scripts/download-actionlint.bash"
+ bash ./download-actionlint.bash "${ACTIONLINT_VERSION}" ./.bin
./.bin/actionlint -version
- name: Run actionlint
diff --git a/.github/workflows/ci-agent-skills.yml b/.github/workflows/ci-agent-skills.yml
index 984c77afa6e4..6a21f594a527 100644
--- a/.github/workflows/ci-agent-skills.yml
+++ b/.github/workflows/ci-agent-skills.yml
@@ -14,10 +14,6 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'push' && github.sha || github.head_ref || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
-env:
- DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_USER }}
- DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
-
jobs:
changes:
permissions:
@@ -58,6 +54,9 @@ jobs:
if: needs.changes.outputs.skills == 'true'
permissions:
contents: read
+ env:
+ DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_USER }}
+ DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -170,6 +169,9 @@ jobs:
if: github.repository_owner == 'PostHog' && github.ref == 'refs/heads/master' && needs.current-master.outputs.is-current == 'true'
permissions:
contents: write
+ env:
+ DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_USER }}
+ DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
diff --git a/.github/workflows/ci-ai.yml b/.github/workflows/ci-ai.yml
index ce498db448fa..90f2bac60799 100644
--- a/.github/workflows/ci-ai.yml
+++ b/.github/workflows/ci-ai.yml
@@ -7,15 +7,14 @@ concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true # We only want one AI CI run per PR concurrently
-env:
- DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_USER }}
- DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
-
jobs:
eval:
timeout-minutes: 45
name: AI evals / ${{ matrix.group }}
runs-on: ubuntu-latest
+ env:
+ DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_USER }}
+ DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
# Skipping on forks as Braintrust credentials are not available there
if: |
github.repository == 'PostHog/posthog' && contains(github.event.pull_request.labels.*.name, 'evals-ready')
diff --git a/.github/workflows/ci-backend.yml b/.github/workflows/ci-backend.yml
index efc0bbd73541..9f2f528820db 100644
--- a/.github/workflows/ci-backend.yml
+++ b/.github/workflows/ci-backend.yml
@@ -33,8 +33,6 @@ env:
# (key is posthog-schema-mig-<epoch>-<hash>). Single-sourced so it can't drift
# between the merge-base (PR) and HEAD (push) key computations below.
SCHEMA_CACHE_EPOCH: v1
- DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_USER }}
- DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
SECRET_KEY: '6b01eee4f945ca25045b5aab440b953461faf08693a9abbf1166dc7c6b9772da' # unsafe - for testing only
DATABASE_URL: 'postgres://posthog:posthog@localhost:5432/posthog'
REDIS_URL: 'redis://localhost'
@@ -660,6 +658,9 @@ jobs:
fail-fast: false
matrix:
include: ${{ fromJson(needs.turbo-discover.outputs.matrix) }}
+ env:
+ DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_USER }}
+ DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -1035,6 +1036,9 @@ jobs:
name: Validate migrations
runs-on: depot-ubuntu-latest
+ env:
+ DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_USER }}
+ DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -1670,6 +1674,9 @@ jobs:
name: Validate OpenAPI types
runs-on: depot-ubuntu-latest
+ env:
+ DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_USER }}
+ DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -2087,6 +2094,9 @@ jobs:
fail-fast: false
matrix:
include: ${{ fromJson(needs.build_django_matrix.outputs.include) }}
+ env:
+ DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_USER }}
+ DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -2956,6 +2966,9 @@ jobs:
(needs.turbo-discover.result != 'success' && needs.turbo-discover.result != 'skipped'))
runs-on: depot-ubuntu-latest
timeout-minutes: 30
+ env:
+ DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_USER }}
+ DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
steps:
- name: 'Checkout repo'
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
diff --git a/.github/workflows/ci-dagster.yml b/.github/workflows/ci-dagster.yml
index 96b2cd137b72..e4251ba7ae62 100644
--- a/.github/workflows/ci-dagster.yml
+++ b/.github/workflows/ci-dagster.yml
@@ -20,8 +20,6 @@ permissions:
pull-requests: read
env:
- DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_USER }}
- DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
SECRET_KEY: '6b01eee4f945ca25045b5aab440b953461faf08693a9abbf1166dc7c6b9772da' # unsafe - for testing only
DATABASE_URL: 'postgres://posthog:posthog@localhost:5432/posthog'
REDIS_URL: 'redis://localhost'
@@ -250,6 +248,9 @@ jobs:
include: ${{ fromJson(needs.changes.outputs.matrix_include || '[]') }}
if: needs.changes.outputs.dagster == 'true'
runs-on: depot-ubuntu-latest
+ env:
+ DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_USER }}
+ DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
steps:
- name: 'Checkout repo'
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
diff --git a/.github/workflows/ci-e2e-playwright.yml b/.github/workflows/ci-e2e-playwright.yml
index a983fd828017..6f2cc223fac9 100644
--- a/.github/workflows/ci-e2e-playwright.yml
+++ b/.github/workflows/ci-e2e-playwright.yml
@@ -31,8 +31,6 @@ permissions:
contents: read
env:
- DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_USER }}
- DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
SECRET_KEY: '6b01eee4f945ca25045b5aab440b953461faf08693a9abbf1166dc7c6b9772da' # unsafe - for testing only
REDIS_URL: redis://localhost
DATABASE_URL: postgres://posthog:posthog@localhost:5432/posthog_e2e_test
@@ -66,12 +64,6 @@ env:
PGPORT: 5432
# this is a fake key so this workflow can run for external contributors as they do not have access to secrets (that we don't need here)
OIDC_RSA_PRIVATE_KEY: ${{ vars.OIDC_RSA_FAKE_PRIVATE_KEY }}
- OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
- ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
- GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
- INKEEP_API_KEY: ${{ secrets.INKEEP_API_KEY }}
- AZURE_INFERENCE_CREDENTIAL: ${{ secrets.AZURE_INFERENCE_CREDENTIAL }}
- AZURE_INFERENCE_ENDPOINT: ${{ secrets.AZURE_INFERENCE_ENDPOINT }}
PERSONHOG_ADDR: 'localhost:50052'
# Internal API auth needs a non-empty INTERNAL_API_SECRET when DEBUG/TEST are off. The dev value
# matches the Node plugins container's non-prod default, so Django<->Node internal calls authenticate.
@@ -246,6 +238,15 @@ jobs:
pull-requests: write
outputs:
vr_run_id: ${{ steps.vr-create.outputs.run_id }}
+ env:
+ DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_USER }}
+ DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
+ OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
+ ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
+ GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
+ INKEEP_API_KEY: ${{ secrets.INKEEP_API_KEY }}
+ AZURE_INFERENCE_CREDENTIAL: ${{ secrets.AZURE_INFERENCE_CREDENTIAL }}
+ AZURE_INFERENCE_ENDPOINT: ${{ secrets.AZURE_INFERENCE_ENDPOINT }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
diff --git a/.github/workflows/ci-hobby.yml b/.github/workflows/ci-hobby.yml
index 3756dbd40eaf..1099ea2b073d 100644
--- a/.github/workflows/ci-hobby.yml
+++ b/.github/workflows/ci-hobby.yml
@@ -679,4 +679,7 @@ jobs:
deployments: write
with:
pr_number: ${{ github.event.pull_request.number }}
- secrets: inherit
+ secrets:
+ DIGITAL_OCEAN_HOBBY_TOKEN: ${{ secrets.DIGITAL_OCEAN_HOBBY_TOKEN }}
+ CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
+ CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
diff --git a/.github/workflows/ci-mcp.yml b/.github/workflows/ci-mcp.yml
index 6823ea0beaa8..8533ad5a1092 100644
--- a/.github/workflows/ci-mcp.yml
+++ b/.github/workflows/ci-mcp.yml
@@ -22,10 +22,6 @@ permissions:
contents: read
pull-requests: read
-env:
- DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_USER }}
- DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
-
jobs:
changes:
runs-on: ubuntu-24.04
@@ -246,6 +242,8 @@ jobs:
# skipped as success, and the ready-for-review run is the merge gate.
if: needs.changes.outputs.mcp == 'true' && github.event.pull_request.draft != true
env:
+ DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_USER }}
+ DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
OPT_OUT_CAPTURE: 1
SECRET_KEY: '6b01eee4f945ca25045b5aab440b953461faf08693a9abbf1166dc7c6b9772da'
DATABASE_URL: 'postgres://posthog:posthog@localhost:5432/posthog'
diff --git a/.github/workflows/ci-nodejs.yml b/.github/workflows/ci-nodejs.yml
index 01a4c9e6e415..ef2eac99201e 100644
--- a/.github/workflows/ci-nodejs.yml
+++ b/.github/workflows/ci-nodejs.yml
@@ -7,8 +7,6 @@ on:
- master
env:
- DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_USER }}
- DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
OBJECT_STORAGE_ENABLED: true
OBJECT_STORAGE_ENDPOINT: 'http://localhost:19000'
OBJECT_STORAGE_ACCESS_KEY_ID: 'object_storage_root_user'
@@ -200,6 +198,8 @@ jobs:
matrix:
shard: [1, 2, 3]
env:
+ DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_USER }}
+ DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
REDIS_URL: 'redis://localhost'
CLICKHOUSE_HOST: 'localhost'
CLICKHOUSE_DATABASE: 'posthog_test'
@@ -391,6 +391,8 @@ jobs:
runs-on: depot-ubuntu-latest-4
timeout-minutes: 30
env:
+ DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_USER }}
+ DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
REDIS_URL: 'redis://localhost'
CLICKHOUSE_HOST: 'localhost'
CLICKHOUSE_DATABASE: 'posthog_test'
diff --git a/.github/workflows/ci-rust.yml b/.github/workflows/ci-rust.yml
index 08e963190a01..f045ed859f29 100644
--- a/.github/workflows/ci-rust.yml
+++ b/.github/workflows/ci-rust.yml
@@ -11,8 +11,6 @@ concurrency:
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
- DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_USER }}
- DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
CARGO_TERM_COLOR: always
UV_HTTP_TIMEOUT: 120
@@ -291,6 +289,9 @@ jobs:
timeout-minutes: 20
permissions:
contents: read
+ env:
+ DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_USER }}
+ DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
defaults:
run:
diff --git a/.github/workflows/pr-cleanup.yml b/.github/workflows/pr-cleanup.yml
index 8fd7019ff54b..9fc379740df2 100644
--- a/.github/workflows/pr-cleanup.yml
+++ b/.github/workflows/pr-cleanup.yml
@@ -10,6 +10,13 @@ on:
description: 'Specific PR number to cleanup (optional)'
type: string
required: false
+ secrets:
+ DIGITAL_OCEAN_HOBBY_TOKEN:
+ required: true
+ CLOUDFLARE_API_TOKEN:
+ required: true
+ CLOUDFLARE_ACCOUNT_ID:
+ required: true
workflow_dispatch:
inputs:
pr_number:
diff --git a/.github/workflows/pr-closed.yml b/.github/workflows/pr-closed.yml
index b99c68fb1cdc..a96736c51d58 100644
--- a/.github/workflows/pr-closed.yml
+++ b/.github/workflows/pr-closed.yml
@@ -19,7 +19,10 @@ jobs:
deployments: write
with:
pr_number: '${{ github.event.pull_request.number }}'
- secrets: inherit
+ secrets:
+ DIGITAL_OCEAN_HOBBY_TOKEN: ${{ secrets.DIGITAL_OCEAN_HOBBY_TOKEN }}
+ CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
+ CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
disable-canary-flags:
name: Disable feature flags canary
diff --git a/.github/workflows/rust-docker-build.yml b/.github/workflows/rust-docker-build.yml
index c604ad74f912..89494169fb7c 100644
--- a/.github/workflows/rust-docker-build.yml
+++ b/.github/workflows/rust-docker-build.yml
@@ -91,7 +91,9 @@ jobs:
type=semver,pattern={{major}}.{{minor}}
type=sha
timeout-minutes: 30
- secrets: inherit
+ secrets:
+ POSTHOG_API_TOKEN: ${{ secrets.POSTHOG_API_TOKEN }}
+ POSTHOG_DEVEX_PROJECT_API_TOKEN: ${{ secrets.POSTHOG_DEVEX_PROJECT_API_TOKEN }}
permissions:
id-token: write
contents: read
diff --git a/.github/workflows/rust-smoke-test-build.yml b/.github/workflows/rust-smoke-test-build.yml
index 1bac6598c2a7..4854dfce0e72 100644
--- a/.github/workflows/rust-smoke-test-build.yml
+++ b/.github/workflows/rust-smoke-test-build.yml
@@ -90,7 +90,9 @@ jobs:
timeout-minutes: 30
event-name: posthog-rust-smoke-test-image-build
extra-failure-props: '"pr": "${{ github.event.pull_request.number }}"'
- secrets: inherit
+ secrets:
+ POSTHOG_API_TOKEN: ${{ secrets.POSTHOG_API_TOKEN }}
+ POSTHOG_DEVEX_PROJECT_API_TOKEN: ${{ secrets.POSTHOG_DEVEX_PROJECT_API_TOKEN }}
permissions:
id-token: write
contents: read