forked from molecule-ai/molecule-core
When a bot opens a PR against main and there's already another PR on the same head branch targeting staging, GitHub's PATCH /pulls returns 422 with: "A pull request already exists for base branch 'staging' and head branch '<branch>'" Pre-fix: the retarget Action exited 1 with no further action. The target-main PR sat there as a duplicate, the workflow run showed red, and someone had to manually close the duplicate. Today's case (#1881 duplicate of #1820) had to be closed manually. Fix: catch that specific 422 message and close the main-PR as redundant instead of failing. Any OTHER 422 (or other error) still fails loud — the grep matches the specific duplicate-base text, not a blanket "any 422 means duplicate". Behaviour matrix: PATCH succeeds → retargeted, explainer comment posted PATCH 422 "already exists for staging" → close main-PR with explainer (NEW) PATCH any other failure → workflow fails (preserves loud-fail for real bugs) Tests: GitHub Actions don't have an inline unit-test framework here. The workflow YAML parses (validated locally) and the bash logic is straightforward. Real verification will be the next duplicate-PR scenario in production. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| auto-promote-staging.yml | ||
| block-internal-paths.yml | ||
| canary-staging.yml | ||
| canary-verify.yml | ||
| check-merge-group-trigger.yml | ||
| ci.yml | ||
| codeql.yml | ||
| e2e-api.yml | ||
| e2e-staging-canvas.yml | ||
| e2e-staging-saas.yml | ||
| e2e-staging-sanity.yml | ||
| promote-latest.yml | ||
| publish-canvas-image.yml | ||
| publish-workspace-server-image.yml | ||
| redeploy-tenants-on-main.yml | ||
| retarget-main-to-staging.yml | ||
| sweep-stale-e2e-orgs.yml | ||