Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Allow Metabase forks (including private ones) to sync automatically (#71663)

Nemanja Glumaccc7506cc6f2e
diff --git a/.github/workflows/cache-generator.yml b/.github/workflows/cache-generator.yml
index 14c94a9191e..b2fa54bdb69 100644
--- a/.github/workflows/cache-generator.yml
+++ b/.github/workflows/cache-generator.yml
@@ -39,6 +39,7 @@ concurrency:
jobs:
get-cache-keys:
+ if: ${{ github.event_name != 'schedule' || github.repository == 'metabase/metabase' }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
steps:
- uses: actions/checkout@v4
diff --git a/.github/workflows/codespell.yml b/.github/workflows/codespell.yml
index 8535b50a7a7..f88ee0472e9 100644
--- a/.github/workflows/codespell.yml
+++ b/.github/workflows/codespell.yml
@@ -8,6 +8,7 @@ on:
jobs:
codespell:
+ if: ${{ github.event_name != 'schedule' || github.repository == 'metabase/metabase' }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 30
permissions:
diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml
index 1341f6be0a1..66d53ddbf2c 100644
--- a/.github/workflows/coverage.yml
+++ b/.github/workflows/coverage.yml
@@ -7,6 +7,7 @@ on:
jobs:
fe-test-coverage:
+ if: ${{ github.event_name != 'schedule' || github.repository == 'metabase/metabase' }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 60
steps:
diff --git a/.github/workflows/disabled-drivers-slack-notification.yml b/.github/workflows/disabled-drivers-slack-notification.yml
index 9910976ee50..c3d2af957e1 100644
--- a/.github/workflows/disabled-drivers-slack-notification.yml
+++ b/.github/workflows/disabled-drivers-slack-notification.yml
@@ -7,6 +7,7 @@ on:
jobs:
notify-disabled-drivers:
+ if: ${{ github.event_name != 'schedule' || github.repository == 'metabase/metabase' }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 5
steps:
diff --git a/.github/workflows/docs-master-generate.yml b/.github/workflows/docs-master-generate.yml
index 71140d96355..d0ccb90f842 100644
--- a/.github/workflows/docs-master-generate.yml
+++ b/.github/workflows/docs-master-generate.yml
@@ -7,6 +7,7 @@ on:
jobs:
update-master-docs:
+ if: ${{ github.event_name != 'schedule' || github.repository == 'metabase/metabase' }}
name: Call documentation update for master
uses: ./.github/workflows/docs-generate-base.yml
with:
diff --git a/.github/workflows/docs-release-generate.yml b/.github/workflows/docs-release-generate.yml
index eaeaf26d713..ea8ba0d0823 100644
--- a/.github/workflows/docs-release-generate.yml
+++ b/.github/workflows/docs-release-generate.yml
@@ -13,6 +13,7 @@ on:
jobs:
update-release-docs:
+ if: ${{ github.event_name != 'schedule' || github.repository == 'metabase/metabase' }}
name: Call documentation update for release branch
uses: ./.github/workflows/docs-generate-base.yml
with:
diff --git a/.github/workflows/js-stats-update.yml b/.github/workflows/js-stats-update.yml
index 44678c98c3e..1ea1b7b9fbf 100644
--- a/.github/workflows/js-stats-update.yml
+++ b/.github/workflows/js-stats-update.yml
@@ -7,6 +7,7 @@ on:
jobs:
js-stats:
+ if: ${{ github.event_name != 'schedule' || github.repository == 'metabase/metabase' }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 5
steps:
diff --git a/.github/workflows/module-boundaries-stats.yml b/.github/workflows/module-boundaries-stats.yml
index 862f1bf40af..cfe9eb97839 100644
--- a/.github/workflows/module-boundaries-stats.yml
+++ b/.github/workflows/module-boundaries-stats.yml
@@ -7,6 +7,7 @@ on:
jobs:
module-boundaries-stats:
+ if: ${{ github.event_name != 'schedule' || github.repository == 'metabase/metabase' }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 10
steps:
diff --git a/.github/workflows/sync-fork.yml b/.github/workflows/sync-fork.yml
new file mode 100644
index 00000000000..7af2a49ad28
--- /dev/null
+++ b/.github/workflows/sync-fork.yml
@@ -0,0 +1,84 @@
+name: Sync Fork with Upstream
+
+on:
+ schedule:
+ - cron: "0 2 * * *" # Every day at 2 AM UTC
+ workflow_dispatch:
+ inputs:
+ release_branch_count:
+ description: "Number of most recent release branches to sync (0 to skip)"
+ required: false
+ default: "5"
+ type: number
+
+jobs:
+ sync-master:
+ # ONLY run on internal metabase org forks — NEVER on the public repo or external forks
+ if: github.repository_owner == 'metabase' && github.repository != 'metabase/metabase'
+ runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+ with:
+ ref: master
+ fetch-depth: 0
+ token: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Add upstream remote
+ run: git remote add metabase https://github.com/metabase/metabase.git
+
+ - name: Fetch upstream master
+ run: git fetch metabase master
+
+ - name: Force-sync master from upstream
+ run: |
+ if git diff --quiet master metabase/master; then
+ echo "master is already up to date — skipping push"
+ else
+ git checkout master
+ git reset --hard metabase/master
+ git push origin master --force
+ fi
+
+ sync-release-branches:
+ # ONLY run on internal metabase org forks — NEVER on the public repo or external forks
+ if: github.repository_owner == 'metabase' && github.repository != 'metabase/metabase'
+ runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+ token: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Add upstream remote
+ run: git remote add metabase https://github.com/metabase/metabase.git
+
+ - name: Fetch upstream release branches
+ run: git fetch metabase 'refs/heads/release-*:refs/remotes/metabase/release-*'
+
+ - name: Force-sync most recent release branches from upstream
+ env:
+ BRANCH_COUNT: ${{ inputs.release_branch_count || '5' }}
+ run: |
+ # Get only canonical release branches (release-x.NN.x), skip ad-hoc branches like backports
+ branches=$(git branch -r --list 'metabase/release-*' | sed 's|^ *||' | grep -E '^metabase/release-x\.[0-9]+\.x$' | sort -t. -k2,2rn | head -n "$BRANCH_COUNT")
+
+ for branch in $branches; do
+ branch_name="${branch#metabase/}"
+ echo "::group::$branch_name"
+
+ # Check if branch exists locally (on origin)
+ if git rev-parse --verify "origin/$branch_name" &>/dev/null; then
+ if git diff --quiet "origin/$branch_name" "$branch"; then
+ echo "$branch_name is already up to date — skipping push"
+ echo "::endgroup::"
+ continue
+ fi
+ fi
+
+ echo "Syncing $branch_name..."
+ git checkout -B "$branch_name" "$branch"
+ git push origin "$branch_name" --force
+ echo "::endgroup::"
+ done
diff --git a/.github/workflows/translation-context.yml b/.github/workflows/translation-context.yml
index bd520e0e200..a01d6fdd715 100644
--- a/.github/workflows/translation-context.yml
+++ b/.github/workflows/translation-context.yml
@@ -7,6 +7,7 @@ on:
jobs:
harvest:
+ if: ${{ github.event_name != 'schedule' || github.repository == 'metabase/metabase' }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
permissions:
contents: read
diff --git a/.github/workflows/translation-update.yml b/.github/workflows/translation-update.yml
index 370572d8472..c767eb32c2d 100644
--- a/.github/workflows/translation-update.yml
+++ b/.github/workflows/translation-update.yml
@@ -10,6 +10,7 @@ permissions:
jobs:
synchronize-translations:
+ if: ${{ github.event_name != 'schedule' || github.repository == 'metabase/metabase' }}
name: Synchronize Translations
env:
BRANCH_NAME: update-translations-${{ github.run_id }}
diff --git a/.github/workflows/update-e2e-timings.yml b/.github/workflows/update-e2e-timings.yml
index a4a87798e83..2e1cfeff1ad 100644
--- a/.github/workflows/update-e2e-timings.yml
+++ b/.github/workflows/update-e2e-timings.yml
@@ -18,6 +18,7 @@ on:
jobs:
collect-and-average-timings:
+ if: ${{ github.event_name != 'schedule' || github.repository == 'metabase/metabase' }}
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 30
env:
diff --git a/.github/workflows/upgrade-deps.yml b/.github/workflows/upgrade-deps.yml
index 5a84c5f33a6..e3aaaedef93 100644
--- a/.github/workflows/upgrade-deps.yml
+++ b/.github/workflows/upgrade-deps.yml
@@ -17,6 +17,7 @@ permissions:
jobs:
bump-deps:
+ if: ${{ github.event_name != 'schedule' || github.repository == 'metabase/metabase' }}
name: Open PRs to Bump Backend Deps
runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}
timeout-minutes: 20