|
30 | 30 |
|
31 | 31 | env: |
32 | 32 | 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 }}" |
33 | 35 |
|
34 | 36 | steps: |
35 | 37 | - name: Validate inputs |
@@ -69,39 +71,24 @@ jobs: |
69 | 71 | - name: Generate models from OpenAPI spec |
70 | 72 | run: uv run datamodel-codegen --input openapi-spec/openapi.json |
71 | 73 |
|
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 |
88 | 84 |
|
89 | 85 | - name: Create or update PR |
90 | | - if: steps.changes.outputs.changed == 'true' |
| 86 | + if: steps.commit.outputs.committed == 'true' |
91 | 87 | id: pr |
92 | 88 | env: |
93 | 89 | GH_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }} |
94 | 90 | run: | |
95 | | - BRANCH="update-models-docs-pr-${DOCS_PR_NUMBER}" |
96 | 91 | 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 | | -
|
105 | 92 | EXISTING_PR=$(gh pr list --head "$BRANCH" --json url --jq '.[0].url' 2>/dev/null || true) |
106 | 93 |
|
107 | 94 | if [[ -n "$EXISTING_PR" ]]; then |
@@ -134,7 +121,7 @@ jobs: |
134 | 121 |
|
135 | 122 | # Post a cross-repo comment on the original docs PR so reviewers know about the corresponding client-python PR. |
136 | 123 | - name: Comment on apify-docs PR |
137 | | - if: steps.changes.outputs.changed == 'true' |
| 124 | + if: steps.commit.outputs.committed == 'true' |
138 | 125 | env: |
139 | 126 | GH_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }} |
140 | 127 | PR_CREATED: ${{ steps.pr.outputs.created }} |
|
0 commit comments