Skip to content

Commit 7fd80c3

Browse files
authored
Enhance auto-merge logic for OpenAPI update PRs (#764)
Added logic to wait for PR creation and find the most recent PR for auto-merge.
1 parent 9d43072 commit 7fd80c3

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

.github/workflows/update-openapi.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,16 @@ jobs:
2424
update_from_source: true
2525
add_timestamp: true
2626
- name: Enable auto-merge
27-
if: steps.sync-openapi.outputs.pr_number != ''
2827
env:
2928
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3029
run: |
31-
gh pr merge ${{ steps.sync-openapi.outputs.pr_number }} --auto --squash
30+
# Wait a moment for PR to be fully created
31+
sleep 5
32+
# Get the most recent PR that starts with update-openapi-spec
33+
PR_NUMBER=$(gh pr list --head update-openapi-spec --json number,headRefName --jq 'map(select(.headRefName | startswith("update-openapi-spec"))) | .[0].number')
34+
if [ -n "$PR_NUMBER" ] && [ "$PR_NUMBER" != "null" ]; then
35+
echo "Found PR #$PR_NUMBER, enabling auto-merge"
36+
gh pr merge $PR_NUMBER --auto --squash
37+
else
38+
echo "No PR found for branch starting with update-openapi-spec"
39+
fi

0 commit comments

Comments
 (0)