From 59ac9479e4675cb052723b971cc02064e85209c8 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Wed, 25 Jun 2025 12:30:10 +0200 Subject: [PATCH] workflows/labels: fix merge conflict label The previous implementation had two problems: - When switching from /search to /pulls, we disabled the additional GET on each single pull request - which causes no test merge commit creation for all PRs. This means, merge conflicts will not actually be detected. - By using `item` in the pull-request triggered case, this goes back to `context.payload.pull_request`, which is the state *at the beginning* of the workflow run. But this renders our "let's wait 3 minutes before checking merge_commit_sha" logic void. While we wait for 3 minutes, we still use the *old* value afterwards... Just making the extra request every time simplifies the logic and solves both problems. --- .github/workflows/labels.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml index 1aa46d751206..3421ef77da5e 100644 --- a/.github/workflows/labels.yml +++ b/.github/workflows/labels.yml @@ -136,12 +136,9 @@ jobs: const pull_number = item.number const issue_number = item.number - // The search result is of a format that works for both issues and pull requests and thus - // does not have all fields of a full pull_request response. Notably, it is missing `head.sha`, - // which we need to fetch the workflow run below. This field is already available non-search sources. - // This API request is also important for the merge-conflict label, because it triggers the + // This API request is important for the merge-conflict label, because it triggers the // creation of a new test merge commit. This is needed to actually determine the state of a PR. - const pull_request = item.head ? item : (await github.rest.pulls.get({ + const pull_request = (await github.rest.pulls.get({ ...context.repo, pull_number })).data