|
26 | 26 | with: |
27 | 27 | script: | |
28 | 28 | const { owner, repo } = context.repo; |
29 | | - const stateLabels = ['awaiting-author', 'awaiting-review']; |
| 29 | + const stateLabels = ['awaiting-author', 'awaiting-review', 'has-conflicts']; |
30 | 30 |
|
31 | 31 | // When triggered by a single PR event, only reconcile that PR. |
32 | 32 | // The hourly schedule and workflow_dispatch reconcile all open PRs. |
@@ -125,6 +125,22 @@ jobs: |
125 | 125 | continue; |
126 | 126 | } |
127 | 127 |
|
| 128 | + // `mergeable`/`mergeable_state` are only returned by the single-PR GET |
| 129 | + // endpoint, and are computed asynchronously by GitHub — a PR fetched via |
| 130 | + // pulls.list (schedule/workflow_dispatch runs) never has them, and even a |
| 131 | + // single-PR fetch can return `null`/"unknown" if the merge check hasn't |
| 132 | + // finished yet. Re-fetch the single PR to get a fresh value, and treat |
| 133 | + // "unknown" as not-yet-computed rather than as conflicting. |
| 134 | + const prDetail = prNumber |
| 135 | + ? pr |
| 136 | + : (await github.rest.pulls.get({ owner, repo, pull_number: pr.number })).data; |
| 137 | +
|
| 138 | + if (prDetail.mergeable === false && prDetail.mergeable_state === 'dirty') { |
| 139 | + core.info(`PR #${pr.number}: has merge conflicts — labeling has-conflicts`); |
| 140 | + await reconcileLabels(pr, 'has-conflicts'); |
| 141 | + continue; |
| 142 | + } |
| 143 | +
|
128 | 144 | // Check CI status for required checks on the PR's head commit only. |
129 | 145 | // Scoping to required checks avoids advisory checks (e.g. codecov/patch) |
130 | 146 | // incorrectly blocking label assignment on otherwise-ready PRs. |
|
0 commit comments