Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions .github/workflows/manual_regenerate_models.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 }}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit - there might still be a race condition when someone creates the branch manually (outside of the github workflow), but that's super unlikely.


- name: Create or update PR
if: steps.commit.outputs.committed == 'true'
Expand Down
Loading