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): check for snapshot patches before the checkout (#104882)

Raúl Negrón-Oterob0d73c8dfc73
diff --git a/.depot/workflows/ci-backend.yml b/.depot/workflows/ci-backend.yml
index dc410a72a8c0..dc2e249f0257 100644
--- a/.depot/workflows/ci-backend.yml
+++ b/.depot/workflows/ci-backend.yml
@@ -3613,22 +3613,8 @@ jobs:
runs-on: depot-ubuntu-24.04
timeout-minutes: 5
steps:
- # Use GitHub app token so Actions run after commiting updated snapshots
- - name: Get app token
- id: app-token
- 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: Checkout
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- with:
- ref: ${{ github.event.pull_request.head.sha }}
- repository: ${{ github.event.pull_request.head.repo.full_name }}
- token: ${{ steps.app-token.outputs.token }}
- fetch-depth: 1
-
+ # Look for patches before the checkout. Most runs have none, and the required
+ # gate waits for this job.
- name: Download all snapshot patches
id: download-patches
continue-on-error: true
@@ -3656,6 +3642,24 @@ jobs:
echo "Patch files empty or missing - no snapshot changes"
fi
+ # Use GitHub app token so Actions run after commiting updated snapshots
+ - name: Get app token
+ if: steps.check-patches.outputs.has-patches == 'true'
+ id: app-token
+ 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: Checkout
+ if: steps.check-patches.outputs.has-patches == 'true'
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ ref: ${{ github.event.pull_request.head.sha }}
+ repository: ${{ github.event.pull_request.head.repo.full_name }}
+ token: ${{ steps.app-token.outputs.token }}
+ fetch-depth: 1
+
# The commit action loads from the PR head, and a head that predates it would fail
# with "action manifest not found" instead of saying what to do.
- name: Require a PR head with the commit action
diff --git a/.github/workflows/ci-backend.yml b/.github/workflows/ci-backend.yml
index 4d831ca880e3..091e175fb7ae 100644
--- a/.github/workflows/ci-backend.yml
+++ b/.github/workflows/ci-backend.yml
@@ -3969,22 +3969,8 @@ jobs:
contents: write
pull-requests: write
steps:
- # Use GitHub app token so Actions run after commiting updated snapshots
- - name: Get app token
- id: app-token
- 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: Checkout
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- with:
- ref: ${{ github.event.pull_request.head.sha }}
- repository: ${{ github.event.pull_request.head.repo.full_name }}
- token: ${{ steps.app-token.outputs.token }}
- fetch-depth: 1
-
+ # Look for patches before the checkout. Most runs have none, and the required
+ # gate waits for this job.
- name: Download all snapshot patches
id: download-patches
continue-on-error: true
@@ -4012,6 +3998,24 @@ jobs:
echo "Patch files empty or missing - no snapshot changes"
fi
+ # Use GitHub app token so Actions run after commiting updated snapshots
+ - name: Get app token
+ if: steps.check-patches.outputs.has-patches == 'true'
+ id: app-token
+ 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: Checkout
+ if: steps.check-patches.outputs.has-patches == 'true'
+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ ref: ${{ github.event.pull_request.head.sha }}
+ repository: ${{ github.event.pull_request.head.repo.full_name }}
+ token: ${{ steps.app-token.outputs.token }}
+ fetch-depth: 1
+
- name: Commit snapshots
if: steps.check-patches.outputs.has-patches == 'true'
uses: ./.github/actions/commit-snapshots