: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(ci): reduce GITHUB_TOKEN burn in alerts and ci-report comments (#75065)
Raúl Negrón-Otero37abdfa2f4c0
diff --git a/.depot/workflows/ci-backend.yml b/.depot/workflows/ci-backend.ymlindex 5d903851e574..059700453ef7 100644--- a/.depot/workflows/ci-backend.yml+++ b/.depot/workflows/ci-backend.yml@@ -12,7 +12,9 @@# - action paths: ./.depot/actions/... instead of ./.github/actions/... (pnpm-install# and setup-sqlx-cli are byte-equivalent mirrors of the canonical composites)# - permissions: pull-requests:read (no comment/auto-commit side effects)-# - Stripped side effects: artifact uploads, CI report section posters, snapshot+# - Stripped side effects: artifact uploads, CI report section posters (canonical+# additionally skips these on trunk-merge/** branches to save GITHUB_TOKEN budget;+# the shadow strips them entirely, so that gating has nothing to mirror), snapshot# auto-commit (handle-snapshots), posthog-github-action telemetry (including the# capture-test-selection job — select-tests still emits its telemetry outputs to# stay apples-to-apples, they just have no consumer here),diff --git a/.github/scripts/monitor-github-rate-limit.js b/.github/scripts/monitor-github-rate-limit.jsindex 3d456d5f2df0..b27a6c810a57 100644--- a/.github/scripts/monitor-github-rate-limit.js+++ b/.github/scripts/monitor-github-rate-limit.js@@ -54,9 +54,10 @@ function buildTrigger(context) {}// `source` identifies which rate-limit bucket the snapshot came from: the-// per-repo default GITHUB_TOKEN, or a dedicated GitHub App installation bucket-// (e.g. posthog-devex-general, the setup-action offload bucket). The two are-// separate 15k buckets, so downstream they're a per-bucket time series.+// per-repo default GITHUB_TOKEN (30k/hr core on this repo), or a dedicated+// GitHub App installation bucket (e.g. posthog-devex-general, the setup-action+// offload bucket, 15k/hr). The buckets are independent, so downstream they're+// a per-bucket time series.function buildProperties({ resource, snapshot, observedAt, observedAtSeconds, repo, runId, trigger, source = DEFAULT_SOURCE }) {const used = typeof snapshot.used === 'number' ? snapshot.used : snapshot.limit - snapshot.remainingconst utilization = snapshot.limit > 0 ? used / snapshot.limit : 0diff --git a/.github/workflows/ci-ai.yml b/.github/workflows/ci-ai.ymlindex 85998ea78340..eed531dd9feb 100644--- a/.github/workflows/ci-ai.yml+++ b/.github/workflows/ci-ai.yml@@ -186,7 +186,9 @@ jobs:- name: Post eval summary to CI report comment# always() because we want to post even if some eval groups errored- if: always() && github.event_name == 'pull_request'+ # Skipped on trunk-merge/** branches: merge-queue draft PRs are ephemeral and+ # unread, and each section write spends shared GITHUB_TOKEN budget.+ if: always() && github.event_name == 'pull_request' && !startsWith(github.head_ref, 'trunk-merge/')env:GITHUB_TOKEN: ${{ github.token }}run: |diff --git a/.github/workflows/ci-alerts-devex.yml b/.github/workflows/ci-alerts-devex.ymlindex 8d71db4cd935..df39352eabdf 100644--- a/.github/workflows/ci-alerts-devex.yml+++ b/.github/workflows/ci-alerts-devex.yml@@ -65,11 +65,26 @@ jobs:.github/scripts/ci-alerts-devex.jssparse-checkout-cone-mode: false+ # Ticks list runs for every gating workflow (a dozen calls, ~166 worst case)+ # exactly when master push volume peaks, so read through the posthog-tests App+ # bucket (it has actions:read; ci-backend-update-test-timing lists runs with+ # it) instead of the shared per-repo GITHUB_TOKEN. A failed mint falls back+ # to github.token rather than skipping the reconcile.+ - name: Mint posthog-tests GitHub token+ id: app-token+ continue-on-error: true+ uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1+ with:+ client-id: ${{ secrets.GH_APP_POSTHOG_TESTS_APP_ID }}+ private-key: ${{ secrets.GH_APP_POSTHOG_TESTS_PRIVATE_KEY }}+ skip-token-revoke: true+- name: Reconcile master CI incident with Slackuses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0env:SLACK_BOT_TOKEN: ${{ secrets.SLACK_DEVEX_BOT_TOKEN }}with:+ github-token: ${{ steps.app-token.outputs.token || github.token }}script: |const script = require('./.github/scripts/ci-alerts-devex.js')await script({ github, context, core })diff --git a/.github/workflows/ci-backend.yml b/.github/workflows/ci-backend.ymlindex de7fe419208c..8f58b6664b69 100644--- a/.github/workflows/ci-backend.yml+++ b/.github/workflows/ci-backend.yml@@ -1926,7 +1926,9 @@ jobs:- name: Post CH migration SQL to CI report comment# Sticky section in the shared CI report comment so pushes don't spam the PR.# GITHUB_TOKEN is read-only for fork PRs, so only comment on same-repo PRs.- if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository+ # Skipped on trunk-merge/** branches: merge-queue draft PRs are ephemeral and+ # unread, and each section write spends shared GITHUB_TOKEN budget.+ if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && !startsWith(github.head_ref, 'trunk-merge/')env:HAS_CHANGES: ${{ steps.render_ch_sql.outputs.has_changes }}CH_MIGRATION_COUNT: ${{ steps.render_ch_sql.outputs.migration_count }}diff --git a/.github/workflows/ci-e2e-playwright.yml b/.github/workflows/ci-e2e-playwright.ymlindex e530d3e9e254..623e05cdc758 100644--- a/.github/workflows/ci-e2e-playwright.yml+++ b/.github/workflows/ci-e2e-playwright.yml@@ -1046,7 +1046,9 @@ jobs:echo "- Run: [#${{ github.run_number }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})" >> $GITHUB_STEP_SUMMARY- name: Post Playwright section to CI report comment- if: always() && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository+ # Skipped on trunk-merge/** branches: merge-queue draft PRs are ephemeral and+ # unread, and each section write spends shared GITHUB_TOKEN budget.+ if: always() && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && !startsWith(github.head_ref, 'trunk-merge/')continue-on-error: trueenv:DEPLOYMENT_URL: ${{ steps.cf-deploy.outputs.deployment-url }}diff --git a/.github/workflows/ci-frontend.yml b/.github/workflows/ci-frontend.ymlindex 666b1ef74c02..6652da253140 100644--- a/.github/workflows/ci-frontend.yml+++ b/.github/workflows/ci-frontend.yml@@ -457,8 +457,10 @@ jobs:# After the base build the tree is on the BASE branch, so guard for the scripts'# absence (also covers branches predating a check). Budgets are surfaced# warn-only further down.+ # Comment steps skip trunk-merge/**: merge-queue draft PRs are ephemeral and+ # unread, and each section write spends shared GITHUB_TOKEN budget.- name: Clean up legacy per-check CI comments- if: always() && github.event_name == 'pull_request'+ if: always() && github.event_name == 'pull_request' && !startsWith(github.head_ref, 'trunk-merge/')env:GITHUB_TOKEN: ${{ github.token }}run: |@@ -469,7 +471,7 @@ jobs:fi- name: Post CI report — eager graph- if: always() && github.event_name == 'pull_request'+ if: always() && github.event_name == 'pull_request' && !startsWith(github.head_ref, 'trunk-merge/')env:GITHUB_TOKEN: ${{ github.token }}run: |@@ -480,7 +482,7 @@ jobs:fi- name: Post CI report — bundle size- if: always() && github.event_name == 'pull_request'+ if: always() && github.event_name == 'pull_request' && !startsWith(github.head_ref, 'trunk-merge/')env:GITHUB_TOKEN: ${{ github.token }}run: |@@ -491,7 +493,7 @@ jobs:fi- name: Post CI report — dist size- if: always() && github.event_name == 'pull_request'+ if: always() && github.event_name == 'pull_request' && !startsWith(github.head_ref, 'trunk-merge/')env:GITHUB_TOKEN: ${{ github.token }}run: |@@ -502,7 +504,7 @@ jobs:fi- name: Post CI report — toolbar bundle- if: always() && github.event_name == 'pull_request'+ if: always() && github.event_name == 'pull_request' && !startsWith(github.head_ref, 'trunk-merge/')env:GITHUB_TOKEN: ${{ github.token }}run: |diff --git a/.github/workflows/ci-mcp-ui-apps.yml b/.github/workflows/ci-mcp-ui-apps.ymlindex 3ba47b405c98..862f8bedc13a 100644--- a/.github/workflows/ci-mcp-ui-apps.yml+++ b/.github/workflows/ci-mcp-ui-apps.yml@@ -112,7 +112,9 @@ jobs:# all CI checks), then clears any leftover standalone size comment from before# the consolidation. Guarded for unrebased branches that predate the scripts.- name: Post size report to CI report comment- if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository+ # Skipped on trunk-merge/** branches: merge-queue draft PRs are ephemeral and+ # unread, and each section write spends shared GITHUB_TOKEN budget.+ if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && !startsWith(github.head_ref, 'trunk-merge/')env:GITHUB_TOKEN: ${{ github.token }}run: |diff --git a/.github/workflows/monitor-github-rate-limit.yml b/.github/workflows/monitor-github-rate-limit.ymlindex 88f3ee67d9b5..4347d62c2365 100644--- a/.github/workflows/monitor-github-rate-limit.yml+++ b/.github/workflows/monitor-github-rate-limit.yml@@ -13,14 +13,16 @@ name: Monitor GitHub Rate Limit# Alerting belongs downstream in PostHog (windowed thresholds, attribution by# repo) — not in the workflow itself. Keep this file focused on emission.#-# A burn-rate alert is wired up downstream in PostHog (DevEx project, id 347861) —+# A burn-rate alert is wired up downstream in PostHog (DevEx project, id 347861);# these are live PostHog resources, not config in this repo:-# - Insight "GitHub core rate-limit — early-window peak utilization" (short id-# iGGXQ1mF): per hour, the peak `core` utilization among samples with >30 min-# left in the reset window (reset_in_seconds > 1800), which filters out the-# harmless pre-reset sawtooth peak.-# - A PostHog alert on that insight fires when it exceeds 0.8 (80%) — i.e. the-# bucket is burning early, not just spiking right before its hourly reset.+# - Insight "GitHub core rate-limit — hourly peak utilization (alerted)" (short+# id iGGXQ1mF): per hour, the peak `core` utilization across monitored+# buckets. Deliberately unfiltered: restricting it to early-window samples+# (reset_in_seconds > 1800) hides a burn that accelerates in the back half of+# the reset window, which is how the 2026-07-29 exhaustion evaded the alert.+# - A PostHog alert "GitHub core rate-limit hot" fires when the insight exceeds+# 0.8 (80%); the multi-week baseline peak stays below that, so a breach is+# always worth a look.# - A Slack destination relays the firing alert to #alerts-devex (and email).# To change the threshold/window, edit the insight + alert in PostHog, not here.@@ -33,6 +35,18 @@ on:required: falseGH_APP_POSTHOG_DEVEX_GENERAL_PRIVATE_KEY:required: false+ GH_APP_POSTHOG_TESTS_APP_ID:+ required: false+ GH_APP_POSTHOG_TESTS_PRIVATE_KEY:+ required: false+ GH_APP_POSTHOG_PATHS_FILTER_APP_ID:+ required: false+ GH_APP_POSTHOG_PATHS_FILTER_PRIVATE_KEY:+ required: false+ GH_APP_TELEMETRY_APP_ID:+ required: false+ GH_APP_TELEMETRY_PRIVATE_KEY:+ required: falsepush:branches: [master]schedule:@@ -89,3 +103,64 @@ jobs:script: |const script = require('./.github/scripts/monitor-github-rate-limit.js')await script({ github, context, core }, { source: 'posthog-devex-general' })++ # Same pattern for the other high-volume App buckets: posthog-tests (CI+ # alerter, migration-risk checks, test-timing), posthog-paths-filter (the+ # changes jobs across ~22 workflows), and the telemetry app (job-duration+ # emitters). Each is its own 15k/hr bucket, so each gets its own series.+ - name: Mint posthog-tests token+ id: tests-token+ continue-on-error: true+ uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1+ with:+ client-id: ${{ secrets.GH_APP_POSTHOG_TESTS_APP_ID }}+ private-key: ${{ secrets.GH_APP_POSTHOG_TESTS_PRIVATE_KEY }}++ - name: Poll posthog-tests bucket and emit to PostHog+ if: steps.tests-token.outputs.token != ''+ uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0+ env:+ POSTHOG_DEVEX_PROJECT_API_TOKEN: ${{ secrets.POSTHOG_DEVEX_PROJECT_API_TOKEN }}+ with:+ github-token: ${{ steps.tests-token.outputs.token }}+ script: |+ const script = require('./.github/scripts/monitor-github-rate-limit.js')+ await script({ github, context, core }, { source: 'posthog-tests' })++ - name: Mint posthog-paths-filter token+ id: paths-filter-token+ continue-on-error: true+ uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1+ with:+ client-id: ${{ secrets.GH_APP_POSTHOG_PATHS_FILTER_APP_ID }}+ private-key: ${{ secrets.GH_APP_POSTHOG_PATHS_FILTER_PRIVATE_KEY }}++ - name: Poll posthog-paths-filter bucket and emit to PostHog+ if: steps.paths-filter-token.outputs.token != ''+ uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0+ env:+ POSTHOG_DEVEX_PROJECT_API_TOKEN: ${{ secrets.POSTHOG_DEVEX_PROJECT_API_TOKEN }}+ with:+ github-token: ${{ steps.paths-filter-token.outputs.token }}+ script: |+ const script = require('./.github/scripts/monitor-github-rate-limit.js')+ await script({ github, context, core }, { source: 'posthog-paths-filter' })++ - name: Mint posthog-telemetry token+ id: telemetry-token+ continue-on-error: true+ uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1+ with:+ client-id: ${{ secrets.GH_APP_TELEMETRY_APP_ID }}+ private-key: ${{ secrets.GH_APP_TELEMETRY_PRIVATE_KEY }}++ - name: Poll posthog-telemetry bucket and emit to PostHog+ if: steps.telemetry-token.outputs.token != ''+ uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0+ env:+ POSTHOG_DEVEX_PROJECT_API_TOKEN: ${{ secrets.POSTHOG_DEVEX_PROJECT_API_TOKEN }}+ with:+ github-token: ${{ steps.telemetry-token.outputs.token }}+ script: |+ const script = require('./.github/scripts/monitor-github-rate-limit.js')+ await script({ github, context, core }, { source: 'posthog-telemetry' })diff --git a/.github/workflows/pr-housekeeping.yml b/.github/workflows/pr-housekeeping.ymlindex e2f11f171f0e..c72abacb4133 100644--- a/.github/workflows/pr-housekeeping.yml+++ b/.github/workflows/pr-housekeeping.yml@@ -48,6 +48,12 @@ jobs:POSTHOG_DEVEX_PROJECT_API_TOKEN: ${{ secrets.POSTHOG_DEVEX_PROJECT_API_TOKEN }}GH_APP_POSTHOG_DEVEX_GENERAL_APP_ID: ${{ secrets.GH_APP_POSTHOG_DEVEX_GENERAL_APP_ID }}GH_APP_POSTHOG_DEVEX_GENERAL_PRIVATE_KEY: ${{ secrets.GH_APP_POSTHOG_DEVEX_GENERAL_PRIVATE_KEY }}+ GH_APP_POSTHOG_TESTS_APP_ID: ${{ secrets.GH_APP_POSTHOG_TESTS_APP_ID }}+ GH_APP_POSTHOG_TESTS_PRIVATE_KEY: ${{ secrets.GH_APP_POSTHOG_TESTS_PRIVATE_KEY }}+ GH_APP_POSTHOG_PATHS_FILTER_APP_ID: ${{ secrets.GH_APP_POSTHOG_PATHS_FILTER_APP_ID }}+ GH_APP_POSTHOG_PATHS_FILTER_PRIVATE_KEY: ${{ secrets.GH_APP_POSTHOG_PATHS_FILTER_PRIVATE_KEY }}+ GH_APP_TELEMETRY_APP_ID: ${{ secrets.GH_APP_TELEMETRY_APP_ID }}+ GH_APP_TELEMETRY_PRIVATE_KEY: ${{ secrets.GH_APP_TELEMETRY_PRIVATE_KEY }}flags-project-board:# No synchronize: board status only transitions on reviewer/draft