: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): make foss/private sync atomic and faster (#60583)
Tom Piccirelloca696d637955
diff --git a/.github/workflows/foss-sync.yml b/.github/workflows/foss-sync.ymlindex fc95a848dae4..da1eb6335137 100644--- a/.github/workflows/foss-sync.yml+++ b/.github/workflows/foss-sync.yml@@ -28,26 +28,26 @@ jobs:owner: PostHogrepositories: posthog-foss- - name: Sync repositories 1 to 1 - master branch- uses: PostHog/git-sync@29d9a6756e8646d0715d5caa9c66438be7e32a1f # v3- with:- source_repo: 'https://x-access-token:${{ github.token }}@github.com/posthog/posthog.git'- source_branch: 'master'- destination_repo: 'https://x-access-token:${{ steps.app-token.outputs.token }}@github.com/posthog/posthog-foss.git'- destination_branch: 'master'- - name: Sync repositories 1 to 1 – tags- uses: PostHog/git-sync@29d9a6756e8646d0715d5caa9c66438be7e32a1f # v3- with:- source_repo: 'https://x-access-token:${{ github.token }}@github.com/posthog/posthog.git'- source_branch: 'refs/tags/*'- destination_repo: 'https://x-access-token:${{ steps.app-token.outputs.token }}@github.com/posthog/posthog-foss.git'- destination_branch: 'refs/tags/*'- - name: Checkout posthog-foss+ # blob:none skips historical blobs (avoids a full-history clone); the full+ # commit graph keeps pushes connected. Lazy blob fetches need origin auth,+ # so persist-credentials stays default-on.+ - name: Checkout posthoguses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2with:- repository: 'posthog/posthog-foss'- ref: master- token: ${{ steps.app-token.outputs.token }}+ fetch-depth: 0+ filter: blob:none+ fetch-tags: true++ # Stage on a branch, not master, so master never momentarily exposes raw+ # posthog (ee/, non-MIT LICENSE) before the FOSS cleanup commit lands.+ - name: Push master tip to staging branch and sync tags+ env:+ FOSS_TOKEN: ${{ steps.app-token.outputs.token }}+ run: |+ git remote add foss "https://x-access-token:${FOSS_TOKEN}@github.com/posthog/posthog-foss.git"+ git push foss "HEAD:refs/heads/foss-sync-staging" --force+ git push foss "refs/tags/*:refs/tags/*" --force+- name: Change LICENSE to pure MITrun: |sed -i -e '/PostHog Inc\./,/Permission is hereby granted/c\Copyright (c) 2020-2021 PostHog Inc\.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy' LICENSE@@ -60,15 +60,28 @@ jobs:- name: Remove enterprise code and dependabot configrun: rm -rf ee/ .github/dependabot.yml- # Commit via the GitHub API so the commit is signed by GitHub's key- # (required once posthog-foss enforces signed commits). ghcommit-action- # detects modified and deleted tracked files and applies them through- # createCommitOnBranch.+ # Commit via the API (ghcommit-action) so it's signed by GitHub — required+ # once posthog-foss enforces signed commits. Picks up modified + deleted files.- name: Commit "Sync and remove all non-FOSS parts"+ id: foss-commituses: planetscale/ghcommit-action@25309d8005ac7c3bcd61d3fe19b69e0fe47dbdde # v0.2.20with:commit_message: 'Sync and remove all non-FOSS parts'repo: posthog/posthog-foss- branch: master+ branch: foss-sync-stagingenv:GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}++ # Atomically repoint master to the signed commit (clean tip -> clean tip),+ # then drop staging.+ - name: Promote staging to master and clean up+ env:+ GH_TOKEN: ${{ steps.app-token.outputs.token }}+ FOSS_SHA: ${{ steps.foss-commit.outputs.commit-hash }}+ run: |+ if gh api repos/posthog/posthog-foss/git/ref/heads/master >/dev/null 2>&1; then+ gh api -X PATCH repos/posthog/posthog-foss/git/refs/heads/master -f sha="$FOSS_SHA" -F force=true+ else+ gh api repos/posthog/posthog-foss/git/refs -f ref=refs/heads/master -f sha="$FOSS_SHA"+ fi+ gh api -X DELETE repos/posthog/posthog-foss/git/refs/heads/foss-sync-staging || truediff --git a/.github/workflows/private-sync.yml b/.github/workflows/private-sync.ymlindex 779b93cf5c40..f4a4e8020dcc 100644--- a/.github/workflows/private-sync.yml+++ b/.github/workflows/private-sync.yml@@ -27,18 +27,22 @@ jobs:owner: PostHogrepositories: posthog-private- - name: Sync repositories 1 to 1 - master branch- uses: PostHog/git-sync@29d9a6756e8646d0715d5caa9c66438be7e32a1f # v3+ # blob:none skips historical blobs (avoids a full-history clone); the full+ # commit graph keeps pushes connected. Lazy blob fetches need origin auth,+ # so persist-credentials stays default-on.+ - name: Checkout posthog+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2with:- source_repo: 'https://x-access-token:${{ github.token }}@github.com/posthog/posthog.git'- source_branch: 'master'- destination_repo: 'https://x-access-token:${{ steps.app-token.outputs.token }}@github.com/posthog/posthog-private.git'- destination_branch: 'master'+ fetch-depth: 0+ filter: blob:none+ fetch-tags: true- - name: Sync repositories 1 to 1 – tags- uses: PostHog/git-sync@29d9a6756e8646d0715d5caa9c66438be7e32a1f # v3- with:- source_repo: 'https://x-access-token:${{ github.token }}@github.com/posthog/posthog.git'- source_branch: 'refs/tags/*'- destination_repo: 'https://x-access-token:${{ steps.app-token.outputs.token }}@github.com/posthog/posthog-private.git'- destination_branch: 'refs/tags/*'+ # 1:1 mirror: replays posthog's existing signed commits — no new commit, so+ # signing enforcement on posthog-private is unaffected.+ - name: Mirror master and tags to posthog-private+ env:+ PRIVATE_TOKEN: ${{ steps.app-token.outputs.token }}+ run: |+ git remote add private "https://x-access-token:${PRIVATE_TOKEN}@github.com/posthog/posthog-private.git"+ git push private "HEAD:refs/heads/master" --force+ git push private "refs/tags/*:refs/tags/*" --force