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): never move posthog-private master backwards in private sync (#124018)

Sven Lange455a2ec32122
diff --git a/.github/workflows/private-sync.yml b/.github/workflows/private-sync.yml
index 694c38ef4ecd..6c8fb6aa53b6 100644
--- a/.github/workflows/private-sync.yml
+++ b/.github/workflows/private-sync.yml
@@ -4,6 +4,10 @@ on:
push:
branches:
- master
+ # Catches private master up when the run for the last push failed and no newer push follows.
+ schedule:
+ - cron: '4,19,34,49 * * * *'
+ workflow_dispatch:
concurrency:
group: private-sync
@@ -42,10 +46,25 @@ jobs:
# 1:1 mirror: replays posthog's existing signed commits — no new commit, so
# signing enforcement on posthog-private is unaffected.
+ # GitHub can start a push run long after its push, so push the current master tip
+ # rather than the triggering commit, and never force: a stale run must not move
+ # private master back.
- name: Mirror master and tags to posthog-private
env:
PRIVATE_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
+ git fetch origin "+refs/heads/master:refs/remotes/origin/master"
+ target="$(git rev-parse refs/remotes/origin/master)"
git remote add private "https://x-access-token:${PRIVATE_TOKEN}@github.com/PostHog/posthog-private.git"
- git push private "HEAD:refs/heads/master" --force
+ if ! git push private "${target}:refs/heads/master"; then
+ private_tip="$(git ls-remote --exit-code private refs/heads/master)"
+ private_tip="${private_tip%%[[:space:]]*}"
+ # A rejected push only means success if private master already contains the target.
+ if ! git merge-base --is-ancestor "${target}" "${private_tip}" 2>/dev/null; then
+ # This log is public, so it never prints the private tip, which can be a private-only commit.
+ echo "::error::posthog-private master has commits that public master ${target} lacks; refusing to overwrite them."
+ exit 1
+ fi
+ echo "posthog-private master already contains ${target}; nothing to push."
+ fi
git push private "refs/tags/*:refs/tags/*" --force