From 8e92095335d4dc8f2143a0e429e4eb54415701b6 Mon Sep 17 00:00:00 2001 From: Vlada Dusek Date: Thu, 21 May 2026 18:37:11 +0200 Subject: [PATCH] fix: avoid branch clash in regenerate-models workflow --- .github/workflows/manual_regenerate_models.yaml | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/.github/workflows/manual_regenerate_models.yaml b/.github/workflows/manual_regenerate_models.yaml index 0c270eaf..2db60d7b 100644 --- a/.github/workflows/manual_regenerate_models.yaml +++ b/.github/workflows/manual_regenerate_models.yaml @@ -63,15 +63,20 @@ jobs: with: token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }} - # If the branch already exists on the remote (e.g. from a previous run, possibly with reviewer commits), - # check it out to build on top of it instead of starting fresh. - - name: Switch to existing branch or create a new one + # If the branch already exists on the remote (e.g. from a previous run, possibly with reviewer + # commits), check it out so regeneration builds on top of it. Otherwise stay on the default + # branch and let the signed-commit step below create the remote branch — its create-branch + # flow does `git fetch ... $BRANCH:refs/heads/$BRANCH` which fails if $BRANCH is already + # checked out locally. + - name: Set up branch + id: branch-setup run: | if git ls-remote --exit-code --heads origin "$BRANCH" > /dev/null 2>&1; then - git fetch origin "$BRANCH" + git fetch origin "$BRANCH":"$BRANCH" git switch "$BRANCH" + echo "create_branch=false" >> "$GITHUB_OUTPUT" else - git switch -c "$BRANCH" + echo "create_branch=true" >> "$GITHUB_OUTPUT" fi # Download the pre-built OpenAPI spec artifact from the apify-docs workflow run. @@ -112,7 +117,7 @@ jobs: add: 'src/apify_client/_models.py src/apify_client/_typeddicts.py src/apify_client/_literals.py' github-token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }} branch: ${{ env.BRANCH }} - create-branch: 'true' + create-branch: ${{ steps.branch-setup.outputs.create_branch }} - name: Create or update PR if: steps.commit.outputs.committed == 'true'