The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Improve sync-fork workflow ergonomics (#71875)
Nemanja Glumac9537481bb222
diff --git a/.github/workflows/sync-fork.yml b/.github/workflows/sync-fork.ymlindex 2c66908313d..1184ed65e5c 100644--- a/.github/workflows/sync-fork.yml+++ b/.github/workflows/sync-fork.yml@@ -17,6 +17,26 @@ on:type: numberjobs:+ workflow-summary:+ # 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 }}+ timeout-minutes: 5+ steps:+ - name: Generate workflow summary+ run: |+ echo '**Inputs:**' >> $GITHUB_STEP_SUMMARY+ echo '' >> $GITHUB_STEP_SUMMARY+ echo '- `release_branch_count`: ${{ inputs.release_branch_count || 5 }}' >> $GITHUB_STEP_SUMMARY+ echo '- `force`: ${{ inputs.force || false }}' >> $GITHUB_STEP_SUMMARY+ echo '- `trigger`: ${{ github.event_name }}' >> $GITHUB_STEP_SUMMARY+ echo '' >> $GITHUB_STEP_SUMMARY+ if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then+ echo 'triggered by: @${{ github.event.sender.login }}' >> $GITHUB_STEP_SUMMARY+ else+ echo 'triggered by: schedule' >> $GITHUB_STEP_SUMMARY+ fi+sync-master:# ONLY run on internal metabase org forks — NEVER on the public repo or external forksif: github.repository_owner == 'metabase' && github.repository != 'metabase/metabase'@@ -27,7 +47,7 @@ jobs:with:ref: masterfetch-depth: 0- token: ${{ secrets.GITHUB_TOKEN }}+ token: ${{ secrets.METABASE_AUTOMATION_USER_TOKEN }}- name: Add upstream remoterun: git remote add metabase https://github.com/metabase/metabase.git@@ -36,11 +56,13 @@ jobs:run: git fetch metabase master- name: Sync master from upstream+ id: syncenv:FORCE: ${{ inputs.force || 'false' }}run: |if git diff --quiet master metabase/master; thenecho "master is already up to date — skipping push"+ echo "detail=up to date" >> "$GITHUB_OUTPUT"exit 0fi@@ -50,24 +72,40 @@ jobs:echo "⚠️ Force-syncing master (overwriting fork-only commits)"git reset --hard metabase/mastergit push origin master --force+ echo "detail=force-synced" >> "$GITHUB_OUTPUT"elseif git pull metabase master; thengit push origin master+ echo "detail=synced" >> "$GITHUB_OUTPUT"elseecho "::warning::master has diverged from upstream — skipping (use force to override)"+ echo "detail=diverged (skipped)" >> "$GITHUB_OUTPUT"fifi- sync-release-branches:+ - name: Summary+ if: always()+ env:+ REPO: ${{ github.repository }}+ run: |+ if [ "${{ steps.sync.outcome }}" = "success" ]; then+ echo "| [\`master\`](https://github.com/${REPO}/tree/master) | ✅ ${{ steps.sync.outputs.detail }} |" >> $GITHUB_STEP_SUMMARY+ else+ echo "| [\`master\`](https://github.com/${REPO}/tree/master) | ❌ failed |" >> $GITHUB_STEP_SUMMARY+ fi++ list-release-branches:# ONLY run on internal metabase org forks — NEVER on the public repo or external forksif: github.repository_owner == 'metabase' && github.repository != 'metabase/metabase'runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}+ outputs:+ branches: ${{ steps.discover.outputs.branches }}steps:- name: Checkoutuses: actions/checkout@v4with:fetch-depth: 0- token: ${{ secrets.GITHUB_TOKEN }}+ token: ${{ secrets.METABASE_AUTOMATION_USER_TOKEN }}- name: Add upstream remoterun: git remote add metabase https://github.com/metabase/metabase.git@@ -75,39 +113,84 @@ jobs:- name: Fetch upstream release branchesrun: git fetch metabase 'refs/heads/release-*:refs/remotes/metabase/release-*'- - name: Sync most recent release branches from upstream+ - name: Discover release branches to sync+ id: discoverenv:BRANCH_COUNT: ${{ inputs.release_branch_count || '5' }}- FORCE: ${{ inputs.force || 'false' }}run: |# Get only canonical release branches (release-x.NN.x), skip ad-hoc branches like backportsbranches=$(git branch -r --list 'metabase/release-*' | sed 's|^ *||' | grep -E '^metabase/release-x\.[0-9]+\.x$' | sort -t. -k2,2rn | head -n "$BRANCH_COUNT")+ json="[]"for branch in $branches; dobranch_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+ json=$(echo "$json" | jq -c --arg b "$branch_name" '. + [$b]')+ done++ echo "branches=$json" >> "$GITHUB_OUTPUT"+ echo "Release branches to sync: $json"++ sync-release-branch:+ needs: list-release-branches+ if: needs.list-release-branches.outputs.branches != '[]'+ runs-on: ${{ vars.DEFAULT_RUNNER_KEY }}+ strategy:+ fail-fast: false+ matrix:+ branch: ${{ fromJson(needs.list-release-branches.outputs.branches) }}+ steps:+ - name: Checkout+ uses: actions/checkout@v4+ with:+ fetch-depth: 0+ token: ${{ secrets.METABASE_AUTOMATION_USER_TOKEN }}++ - name: Add upstream remote+ run: git remote add metabase https://github.com/metabase/metabase.git++ - name: Fetch upstream branch+ run: git fetch metabase "${{ matrix.branch }}"++ - name: Sync ${{ matrix.branch }} from upstream+ id: sync+ env:+ FORCE: ${{ inputs.force || 'false' }}+ run: |+ branch_name="${{ matrix.branch }}"++ # Check if branch exists on origin+ if git rev-parse --verify "origin/$branch_name" &>/dev/null; then+ if git diff --quiet "origin/$branch_name" "metabase/$branch_name"; then+ echo "$branch_name is already up to date — skipping push"+ echo "detail=up to date" >> "$GITHUB_OUTPUT"+ exit 0fi+ fi- if [ "$FORCE" = "true" ]; then- echo "⚠️ Force-syncing $branch_name (overwriting fork-only commits)"- git checkout -B "$branch_name" "$branch"- git push origin "$branch_name" --force+ if [ "$FORCE" = "true" ]; then+ echo "⚠️ Force-syncing $branch_name (overwriting fork-only commits)"+ git checkout -B "$branch_name" "metabase/$branch_name"+ git push origin "$branch_name" --force+ echo "detail=force-synced" >> "$GITHUB_OUTPUT"+ else+ git checkout -B "$branch_name" "origin/$branch_name" 2>/dev/null || git checkout -B "$branch_name" "metabase/$branch_name"+ if git pull metabase "$branch_name"; then+ git push origin "$branch_name"+ echo "detail=synced" >> "$GITHUB_OUTPUT"else- git checkout -B "$branch_name" "origin/$branch_name" 2>/dev/null || git checkout -B "$branch_name" "$branch"- if git pull metabase "$branch_name"; then- git push origin "$branch_name"- else- echo "::warning::$branch_name has diverged from upstream — skipping (use force to override)"- fi+ echo "::warning::$branch_name has diverged from upstream — skipping (use force to override)"+ echo "detail=diverged (skipped)" >> "$GITHUB_OUTPUT"fi+ fi- echo "::endgroup::"- done+ - name: Summary+ if: always()+ env:+ REPO: ${{ github.repository }}+ run: |+ branch="${{ matrix.branch }}"+ if [ "${{ steps.sync.outcome }}" = "success" ]; then+ echo "| [\`${branch}\`](https://github.com/${REPO}/tree/${branch}) | ✅ ${{ steps.sync.outputs.detail }} |" >> $GITHUB_STEP_SUMMARY+ else+ echo "| [\`${branch}\`](https://github.com/${REPO}/tree/${branch}) | ❌ failed |" >> $GITHUB_STEP_SUMMARY+ fi