From c77cfb9239e1aad89f668e0599f076761d7771ad Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Fri, 23 May 2025 13:05:47 +0200 Subject: [PATCH] workflows: run on merge conflicts as well When a PR is having conflicts with the base branch, we used to skip most jobs depending on the target branch. With this change, we still run those jobs, but without actually merging the PR temporarily. That means we compare the head of the PR with the merge-base of the PR's branch and the target branch - i.e. the point where the PR branched off. This is not 100% accurate, but that's not important, because after resolving the merge conflicts, those workflows will run again anyway. It allows to give early feedback, though, instead of just skipping all the jobs. --- .github/workflows/get-merge-commit.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/get-merge-commit.yml b/.github/workflows/get-merge-commit.yml index 2bb58c5bedb1..8085b3d4d64b 100644 --- a/.github/workflows/get-merge-commit.yml +++ b/.github/workflows/get-merge-commit.yml @@ -68,7 +68,18 @@ jobs: return { mergedSha, targetSha } } else { - throw new Error("The PR has a merge conflict. Skipping the rest...") + console.log("The PR has a merge conflict.") + + const mergedSha = prInfo.head.sha + const targetSha = (await github.rest.repos.compareCommitsWithBasehead({ + owner: context.repo.owner, + repo: context.repo.repo, + basehead: `${prInfo.base.sha}...${prInfo.head.sha}` + })).data.merge_base_commit.sha + + console.log(`Checking the commits:\nmerged:${mergedSha}\ntarget:${targetSha}`) + + return { mergedSha, targetSha } } } throw new Error("Not retrying anymore. It's likely that GitHub is having internal issues: check https://www.githubstatus.com.")