Skip to content

Commit 2acffb4

Browse files
committed
Address feedback
1 parent bdfe4bf commit 2acffb4

File tree

1 file changed

+14
-27
lines changed

1 file changed

+14
-27
lines changed

.github/workflows/regenerate_models.yaml renamed to .github/workflows/manual_regenerate_models.yaml

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ jobs:
3030

3131
env:
3232
DOCS_PR_NUMBER: ${{ inputs.docs_pr_number }}
33+
BRANCH: "update-models-docs-pr-${{ inputs.docs_pr_number }}"
34+
TITLE: "[TODO]: update generated models from apify-docs PR #${{ inputs.docs_pr_number }}"
3335

3436
steps:
3537
- name: Validate inputs
@@ -69,39 +71,24 @@ jobs:
6971
- name: Generate models from OpenAPI spec
7072
run: uv run datamodel-codegen --input openapi-spec/openapi.json
7173

72-
- name: Check for changes
73-
id: changes
74-
run: |
75-
if git diff --exit-code src/apify_client/_models.py; then
76-
echo "No changes in generated models"
77-
echo "changed=false" >> "$GITHUB_OUTPUT"
78-
else
79-
echo "Models have changed"
80-
echo "changed=true" >> "$GITHUB_OUTPUT"
81-
fi
82-
83-
- name: Configure git
84-
if: steps.changes.outputs.changed == 'true'
85-
run: |
86-
git config user.name "apify-service-account"
87-
git config user.email "apify-service-account@users.noreply.github.com"
74+
- name: Commit model changes
75+
id: commit
76+
uses: EndBug/add-and-commit@v9
77+
with:
78+
add: src/apify_client/_models.py
79+
author_name: apify-service-account
80+
author_email: apify-service-account@users.noreply.github.com
81+
message: ${{ env.TITLE }}
82+
new_branch: ${{ env.BRANCH }}
83+
push: --force
8884

8985
- name: Create or update PR
90-
if: steps.changes.outputs.changed == 'true'
86+
if: steps.commit.outputs.committed == 'true'
9187
id: pr
9288
env:
9389
GH_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
9490
run: |
95-
BRANCH="update-models-docs-pr-${DOCS_PR_NUMBER}"
9691
DOCS_PR_URL="https://github.com/apify/apify-docs/pull/${DOCS_PR_NUMBER}"
97-
TITLE="[TODO]: update generated models from apify-docs PR #${DOCS_PR_NUMBER}"
98-
99-
# -B creates the branch or resets it if it already exists (re-runs for the same docs PR).
100-
git checkout -B "$BRANCH"
101-
git add src/apify_client/_models.py
102-
git commit -m "$TITLE"
103-
git push --force origin "$BRANCH"
104-
10592
EXISTING_PR=$(gh pr list --head "$BRANCH" --json url --jq '.[0].url' 2>/dev/null || true)
10693
10794
if [[ -n "$EXISTING_PR" ]]; then
@@ -134,7 +121,7 @@ jobs:
134121
135122
# Post a cross-repo comment on the original docs PR so reviewers know about the corresponding client-python PR.
136123
- name: Comment on apify-docs PR
137-
if: steps.changes.outputs.changed == 'true'
124+
if: steps.commit.outputs.committed == 'true'
138125
env:
139126
GH_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
140127
PR_CREATED: ${{ steps.pr.outputs.created }}

0 commit comments

Comments
 (0)