@@ -2,13 +2,18 @@ name: OpenAPI checks
22
33on :
44 pull_request :
5+ types : [opened, synchronize, reopened, closed]
56 push :
67 branches :
78 - master
89
10+ permissions :
11+ contents : read
12+
913jobs :
1014 lint :
1115 name : Lint specification
16+ if : github.event.action != 'closed'
1217 runs-on : ubuntu-latest
1318
1419 steps :
@@ -119,7 +124,10 @@ jobs:
119124 name : Trigger Python client model regeneration
120125 runs-on : ubuntu-latest
121126 needs : [validate]
122- if : github.event_name == 'pull_request'
127+ if : >-
128+ github.event_name == 'pull_request'
129+ && github.event.action != 'closed'
130+ && github.event.pull_request.head.repo.full_name == github.repository
123131
124132 steps :
125133 - uses : actions/checkout@v6
@@ -137,9 +145,39 @@ jobs:
137145 env :
138146 GITHUB_TOKEN : ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
139147 PR_NUMBER : ${{ github.event.pull_request.number }}
140- PR_BRANCH : ${{ github.head_ref }}
148+ PR_SHA : ${{ github.event.pull_request.head.sha }}
141149 run : |
142150 gh workflow run regenerate_models.yaml \
143151 --repo apify/apify-client-python \
144152 --field docs_pr_number="$PR_NUMBER" \
145- --field docs_pr_branch="$PR_BRANCH"
153+ --field docs_pr_sha="$PR_SHA"
154+
155+ cleanup-client-model-pr :
156+ name : Close Python client model PR on docs PR close
157+ runs-on : ubuntu-latest
158+ if : >-
159+ github.event_name == 'pull_request'
160+ && github.event.action == 'closed'
161+
162+ steps :
163+ - name : Close corresponding apify-client-python PR
164+ env :
165+ GITHUB_TOKEN : ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }}
166+ PR_NUMBER : ${{ github.event.pull_request.number }}
167+ run : |
168+ BRANCH="chore/update-models-docs-pr-${PR_NUMBER}"
169+ EXISTING_PR=$(gh pr list \
170+ --repo apify/apify-client-python \
171+ --head "$BRANCH" \
172+ --json number \
173+ --jq '.[0].number' 2>/dev/null || true)
174+
175+ if [ -n "$EXISTING_PR" ]; then
176+ gh pr close "$EXISTING_PR" \
177+ --repo apify/apify-client-python \
178+ --delete-branch \
179+ --comment "Closing this PR because the source apify-docs PR #${PR_NUMBER} was closed."
180+ echo "Closed apify-client-python PR #$EXISTING_PR"
181+ else
182+ echo "No corresponding apify-client-python PR found for branch $BRANCH"
183+ fi
0 commit comments