From 7f47cdca10ce9305938eb70111787f342f146ba8 Mon Sep 17 00:00:00 2001 From: MQ37 Date: Thu, 27 Aug 2026 14:19:44 +0200 Subject: [PATCH] fix: pick merge method sync_branches actually allows pulls.merge() defaults to a merge commit, which 405s ("Merge commits are not allowed on this repository") on any repo configured to disallow them, e.g. apify/apify-ai-agent. Read the repo's allowed merge methods and pick the first available, merge preferred so unaffected callers keep today's behavior. --- .github/workflows/sync_branches.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/sync_branches.yaml b/.github/workflows/sync_branches.yaml index 5744f645..1d736888 100644 --- a/.github/workflows/sync_branches.yaml +++ b/.github/workflows/sync_branches.yaml @@ -75,11 +75,26 @@ jobs: const pullRequestNumber = createResp.data.number; + // Octokit defaults pulls.merge() to a real merge commit, which 405s on a + // repository configured to disallow merge commits. Pick the first method + // the repo actually allows, preferring a merge commit when it is allowed + // so existing callers keep their current behavior. + const repoResp = await serviceAccountOctokit.rest.repos.get({ + owner: context.repo.owner, + repo: context.repo.repo, + }); + const mergeMethod = repoResp.data.allow_merge_commit + ? 'merge' + : repoResp.data.allow_squash_merge + ? 'squash' + : 'rebase'; + // Merge pull request await serviceAccountOctokit.rest.pulls.merge({ owner: context.repo.owner, repo: context.repo.repo, pull_number: pullRequestNumber, + merge_method: mergeMethod, }); - name: report failure to slack