@@ -26,15 +26,29 @@ jobs:
2626 with :
2727 github-token : ${{secrets.GITHUB_TOKEN}}
2828 script : |
29- let response = await github.rest.pulls.create ({
29+ const pulls = await github.rest.pulls.list ({
3030 owner: context.repo.owner,
3131 repo: context.repo.repo,
32- title: "${{ github.event.client_payload.PullRequestTitle }}",
33- head: "${{ github.event.client_payload.ReleaseBranchName }}-docs",
32+ head: `${context.repo.owner}:${{ github.event.client_payload.ReleaseBranchName }}-docs`,
3433 base: "${{ github.event.client_payload.PullRequestBase }}",
35- body: `${{ github.event.client_payload.PullRequestBody }}`
34+ state: 'open'
3635 });
37- return response.data.number
36+
37+ if (pulls.data.length > 0) {
38+ console.log(`Pull request already exists: ${pulls.data[0].html_url}`);
39+ return pulls.data[0].number;
40+ } else {
41+ console.log('No existing pull request found, creating new one');
42+ let response = await github.rest.pulls.create({
43+ owner: context.repo.owner,
44+ repo: context.repo.repo,
45+ title: "${{ github.event.client_payload.PullRequestTitle }}",
46+ head: "${{ github.event.client_payload.ReleaseBranchName }}-docs",
47+ base: "${{ github.event.client_payload.PullRequestBase }}",
48+ body: `${{ github.event.client_payload.PullRequestBody }}`
49+ });
50+ return response.data.number;
51+ }
3852
3953 - name : Request reviewers
4054 uses : actions/github-script@v7
0 commit comments