fix: rename share-debug route to .tsx for JSX support #97
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 Release Pull Request | |
| on: | |
| push: | |
| branches: | |
| - develop | |
| jobs: | |
| sync-release-pr: | |
| name: Create or update develop → main PR | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Open or update release PR | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| PR_TITLE: "Release: develop → main" | |
| PR_TEMPLATE: .github/PULL_REQUEST_TEMPLATE.md | |
| run: | | |
| set -euo pipefail | |
| if [ ! -f "$PR_TEMPLATE" ]; then | |
| echo "Pull request template not found at $PR_TEMPLATE" | |
| exit 1 | |
| fi | |
| git fetch origin main --prune | |
| BODY_FILE="$(mktemp)" | |
| export BODY_FILE | |
| python3 - <<'PY' | |
| import os | |
| import re | |
| import subprocess | |
| template_path = os.environ["PR_TEMPLATE"] | |
| body_file_path = os.environ["BODY_FILE"] | |
| # Get commits that are in develop but not in main | |
| log = subprocess.check_output( | |
| ["git", "log", "--pretty=format:%s (%h)", "origin/main..HEAD", "--no-merges"], | |
| text=True, | |
| ).strip().splitlines() | |
| # Filter out empty lines | |
| log = [line for line in log if line.strip()] | |
| max_items = 60 | |
| items = log[:max_items] | |
| extra = max(len(log) - len(items), 0) | |
| if items: | |
| bullets = [f"- {line}" for line in items] | |
| if extra: | |
| bullets.append(f"- …and {extra} more commits") | |
| else: | |
| bullets = ["- No new changes since last release"] | |
| with open(template_path, "r", encoding="utf-8") as f: | |
| content = f.read() | |
| lines = content.splitlines() | |
| # Find the Changes section and replace the placeholder | |
| if "## Changes" in lines: | |
| header_index = lines.index("## Changes") | |
| # Find the next section header | |
| end_index = len(lines) | |
| for i in range(header_index + 1, len(lines)): | |
| if lines[i].startswith("## "): | |
| end_index = i | |
| break | |
| # Extract section content | |
| section = lines[header_index + 1 : end_index] | |
| # Find and replace the placeholder bullet point | |
| replaced = False | |
| for idx, line in enumerate(section): | |
| # Match empty bullet point (with optional whitespace) | |
| if re.fullmatch(r"-\s*", line.strip()) or line.strip() == "-": | |
| section = section[:idx] + bullets + section[idx + 1 :] | |
| replaced = True | |
| break | |
| if not replaced: | |
| # If no placeholder found, insert bullets after empty lines/comments | |
| insert_idx = 0 | |
| for idx, line in enumerate(section): | |
| if line.strip() and not line.strip().startswith("<!--"): | |
| insert_idx = idx | |
| break | |
| insert_idx = idx + 1 | |
| section = section[:insert_idx] + bullets + section[insert_idx:] | |
| final_lines = lines[: header_index + 1] + section + lines[end_index:] | |
| else: | |
| # If no Changes section exists, append one | |
| final_lines = lines + ["", "## Changes", ""] + bullets | |
| with open(body_file_path, "w", encoding="utf-8") as f: | |
| f.write("\n".join(final_lines).rstrip() + "\n") | |
| # Debug: print the generated body | |
| print("Generated PR body:") | |
| print("-" * 40) | |
| with open(body_file_path, "r") as f: | |
| print(f.read()) | |
| print("-" * 40) | |
| PY | |
| PR_NUMBER="$(gh pr list --base main --head develop --state open --json number --jq '.[0].number // empty')" | |
| if [ -n "$PR_NUMBER" ]; then | |
| echo "Updating existing PR #$PR_NUMBER" | |
| gh pr edit "$PR_NUMBER" \ | |
| --title "$PR_TITLE" \ | |
| --body-file "$BODY_FILE" | |
| else | |
| echo "Creating new release PR" | |
| gh pr create \ | |
| --base main \ | |
| --head develop \ | |
| --title "$PR_TITLE" \ | |
| --body-file "$BODY_FILE" | |
| fi |