[PMM-612] Comparison: TypeScript (#63) #311
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Sync Public → Private | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - "api-design/**" | |
| - "docs/**" | |
| - "guides/**" | |
| - "mcp/**" | |
| - "openapi/**" | |
| - "**public/assets/**" | |
| env: | |
| SYNC_REPO: ${{ secrets.SYNC_REPO }} | |
| BRANCH: main | |
| SYNC_DIRS: "api-design docs guides mcp openapi" | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout public repo | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Clone private repo | |
| env: | |
| TOKEN: ${{ secrets.SERVICE_BOT_TOKEN }} | |
| run: | | |
| git clone https://x-access-token:${TOKEN}@github.com/${SYNC_REPO}.git private-repo | |
| - name: Sync public folders into private repo content paths | |
| run: | | |
| set -euo pipefail | |
| for dir in $SYNC_DIRS; do | |
| src_dir="$dir" | |
| dest_dir="private-repo/src/content/$dir" | |
| if [ -d "$src_dir" ]; then | |
| echo "Syncing $src_dir → $dest_dir" | |
| rsync -a --delete "$src_dir/" "$dest_dir/" | |
| else | |
| echo "Warning: $src_dir does not exist, skipping..." | |
| fi | |
| done | |
| - name: Sync public assets into private repo content paths | |
| run: | | |
| set -euo pipefail | |
| base_src="public/assets" | |
| base_dest="private-repo/public/assets" | |
| asset_dirs=( | |
| "api-design" | |
| "docs" | |
| "guides" | |
| "mcp" | |
| "openapi" | |
| ) | |
| for dir in "${asset_dirs[@]}"; do | |
| src_assets="${base_src}/${dir}" | |
| dest_assets="${base_dest}/${dir}" | |
| if [ -d "$src_assets" ]; then | |
| echo "Syncing assets $src_assets → $dest_assets" | |
| mkdir -p "$dest_assets" | |
| rsync -a --delete "$src_assets/" "$dest_assets/" | |
| else | |
| echo "Warning: $src_assets does not exist; no assets to sync." | |
| fi | |
| done | |
| - name: Sync _meta.global.tsx into private repo | |
| run: | | |
| set -euo pipefail | |
| src_file="_meta.global.tsx" | |
| dest_file="private-repo/src/app/_meta.global.tsx" | |
| if [ -f "$src_file" ]; then | |
| echo "Syncing file $src_file → $dest_file" | |
| mkdir -p "$(dirname "$dest_file")" | |
| cp "$src_file" "$dest_file" | |
| else | |
| echo "Warning: $src_file does not exist, skipping..." | |
| fi | |
| - name: Commit and push changes to private repo | |
| run: | | |
| set -euo pipefail | |
| cd private-repo | |
| git config user.name "Beezy the bot" | |
| git config user.email "[email protected]" | |
| git add . | |
| if git diff --cached --quiet; then | |
| echo "No changes to sync" | |
| echo "Nothing synced." >> $GITHUB_STEP_SUMMARY | |
| exit 0 | |
| fi | |
| git commit -m "Sync open source content 🐝 (from $GITHUB_SHA)" | |
| if ! git push origin ${BRANCH}; then | |
| echo "❌ Push to private repo failed!" >> $GITHUB_STEP_SUMMARY | |
| echo "Please check for conflicts or access issues." >> $GITHUB_STEP_SUMMARY | |
| exit 1 | |
| fi | |
| COMMIT_SHA=$(git rev-parse HEAD) | |
| echo "### ✅ Synced content to private repo at \`$(date)\`" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Commit SHA:** \`${COMMIT_SHA}\`" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Grouped file changes:**" >> $GITHUB_STEP_SUMMARY | |
| git diff --cached --name-status | awk ' | |
| { | |
| split($2, parts, "/"); | |
| folder = parts[1]; | |
| if (current != folder) { | |
| if (current != "") print "" >> ENVIRON["GITHUB_STEP_SUMMARY"]; | |
| print "#### `" folder "/`" >> ENVIRON["GITHUB_STEP_SUMMARY"]; | |
| current = folder; | |
| } | |
| print $0 >> ENVIRON["GITHUB_STEP_SUMMARY"]; | |
| } | |
| ' |