Fix GITHUB_TOKEN usage in external PR approval flow

Merged
PI
8mo ago
+527-799

why

bug in previous approach

what changed

test plan


Summary by cubic

Fixes the external PR approval flow by switching to the correct GITHUB_TOKEN, stabilizing the mirror/refresh behavior, and ignoring third‑party bot comments when parsing claim markers. Also improves the claude workflow to build the repo before edits and allow rerunning failed jobs.

  • Bug Fixes

    • Use GITHUB_TOKEN for branch pushes and API calls; remove the GitHub App token path.
    • Enable persist-credentials: true during checkout to allow pushes.
    • Keep the mirrored PR open and mark it stale when new commits land on the external PR; relabel both PRs consistently.
    • Auto-handle reopen/close transitions across external and mirrored PRs.
    • Ignore comments from non-managed bots (e.g., Greptile, Cubic); only parse claim markers from github-actions[bot] to avoid false triggers.
  • Refactors

    • Inline a small JS lib (ECPR_LIB) to manage labels, comments, lifecycle, and claims; jobs run in clear phases (external lifecycle → claim prep → branch refresh → claim finalize).
    • Refresh internal branches by rebasing onto the approved external ref; report conflicts cleanly for manual follow-up.
    • Improve claude.yml: upgrade to actions/checkout@v6, set actions: write, run pnpm/turbo build via setup-node-pnpm-turbo, enable track_progress, and use an explicit tool allowlist for anthropics/claude-code-action@v1.