|
| 1 | +name: Sync Repository to Public Mirror |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [closed] |
| 6 | + # No branches filter means it will trigger for ALL branches |
| 7 | + # If you want to sync main branch then add: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + workflow_dispatch: |
| 11 | + inputs: |
| 12 | + force_sync: |
| 13 | + description: 'Force sync all branches (WARNING: This will sync all branches)' |
| 14 | + required: false |
| 15 | + default: false # CRITICAL FIX: Changed from 'true' to false |
| 16 | + type: boolean |
| 17 | + public_repo_name: |
| 18 | + description: 'Public repository name (leave empty to auto-derive by removing "-private")' |
| 19 | + required: false |
| 20 | + type: string |
| 21 | + target_branches: |
| 22 | + description: 'Comma-separated list of specific branches to sync (leave empty to sync merged branch only)' |
| 23 | + required: false |
| 24 | + type: string |
| 25 | + |
| 26 | +# Branch-level concurrency control - allows parallel syncs for different branches |
| 27 | +concurrency: |
| 28 | + group: sync-public-mirror-${{ github.repository }}-${{ github.event.pull_request.base.ref || github.event.client_payload.branch || github.event.inputs.target_branches || 'default' }} |
| 29 | + cancel-in-progress: false # Queue per branch to ensure all changes are synced |
| 30 | + |
| 31 | +jobs: |
| 32 | + call-sync-workflow: |
| 33 | + # Only run this job when the PR was merged, not just closed, OR when manually triggered, OR via repository_dispatch |
| 34 | + if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch' || github.event_name == 'repository_dispatch' |
| 35 | + uses: thoughtspot/workflows/.github/workflows/sync-to-public-mirror.yml@main |
| 36 | + with: |
| 37 | + # CRITICAL FIX: Only force sync when explicitly requested, not on every PR |
| 38 | + force_sync: ${{ github.event.inputs.force_sync == true || (github.event_name == 'repository_dispatch' && github.event.client_payload.force_sync == true) }} |
| 39 | + |
| 40 | + public_repo_name: ${{ github.event.inputs.public_repo_name || github.event.client_payload.public_repo_name || '' }} |
| 41 | + |
| 42 | + # Optimization: Pass specific target branches instead of syncing all |
| 43 | + target_branches: ${{ github.event.inputs.target_branches || github.event.client_payload.target_branches || (github.event_name == 'pull_request' && github.event.pull_request.base.ref) || '' }} |
| 44 | + |
| 45 | + # Enhanced context for better logging and traceability |
| 46 | + trigger_type: ${{ github.event_name }} |
| 47 | + pr_number: ${{ github.event.pull_request.number || github.event.client_payload.pr_number || '' }} |
| 48 | + |
| 49 | + # CRITICAL FIX: Use base.ref (target branch) instead of head.ref (source branch) |
| 50 | + merged_branch: ${{ github.event.pull_request.base.ref || github.event.client_payload.branch || '' }} |
| 51 | + |
| 52 | + merge_commit_sha: ${{ github.event.pull_request.merge_commit_sha || github.event.client_payload.commit_sha || github.sha }} |
| 53 | + secrets: |
| 54 | + SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }} |
0 commit comments