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'