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.

fix(ci): check out the pr head by sha in backend validation jobs (#121194)

Raúl Negrón-Otero876760bb272e
diff --git a/.depot/workflows/ci-backend.yml b/.depot/workflows/ci-backend.yml
index bbf5054be1ed..afb7f24af2c3 100644
--- a/.depot/workflows/ci-backend.yml
+++ b/.depot/workflows/ci-backend.yml
@@ -1913,10 +1913,11 @@ jobs:
- name: Checkout this PR
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
- # For same-repo PRs, checkout the actual branch (not the merge commit)
+ # For same-repo PRs, checkout the PR head commit (not the merge commit)
# so upstream/master..HEAD reflects PR files. Fork PRs fall back
- # to the default merge commit.
- ref: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'PostHog/posthog') && github.event.pull_request.head.ref || github.event_name == 'push' && github.sha || github.ref }}
+ # to the default merge commit. The SHA, not the branch name, because
+ # Trunk can delete a trunk-merge/ branch before this step runs.
+ ref: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'PostHog/posthog') && github.event.pull_request.head.sha || github.event_name == 'push' && github.sha || github.ref }}
clean: false
- name: Install python dependencies for this PR
run: |
@@ -1959,7 +1960,7 @@ jobs:
CHANGED_FILES: ${{ needs.changes.outputs.migrations_review_files }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
run: |
- # The PR checkout above uses the PR branch, which on unrebased PRs
+ # The PR checkout above uses the PR head commit, which on unrebased PRs
# predates this script, so skip the CI report section rather than fail.
# An empty token would leave the ambient Depot token in place, so the
# section skips without one too.
@@ -2080,7 +2081,7 @@ jobs:
env:
CI_REPORT_TOKEN: ${{ steps.ci-report.outputs.available == 'true' && steps.ci-report-app-token.outputs.token || '' }}
run: |
- # The PR checkout above uses the PR branch, which on unrebased PRs
+ # The PR checkout above uses the PR head commit, which on unrebased PRs
# predates this script, so skip the CI report section rather than fail.
# An empty token would leave the ambient Depot token in place, so the
# section skips without one too.
@@ -2483,7 +2484,7 @@ jobs:
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
- ref: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'PostHog/posthog') && github.event.pull_request.head.ref || github.event_name == 'push' && github.sha || github.ref }}
+ ref: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'PostHog/posthog') && github.event.pull_request.head.sha || github.event_name == 'push' && github.sha || github.ref }}
clean: false
- name: Clean up data directories with container permissions
run: |