Skip to content

Commit b8f3c68

Browse files
Update Release and Pull Request creation workflows (#12767)
1 parent 8384138 commit b8f3c68

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

.github/workflows/create_github_release.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ jobs:
1010
runs-on: ubuntu-latest
1111

1212
steps:
13-
- uses: actions/checkout@v4
14-
1513
- name: Create release for ${{ github.event.client_payload.ReleaseBranchName }}
16-
uses: ncipollo/release-action@v1.16.0
14+
uses: ncipollo/release-action@440c8c1cb0ed28b9f43e4d1d670870f059653174 #v1.16.0
1715
with:
1816
tag: ${{ github.event.client_payload.ReleaseBranchName }}
1917
name: ${{ github.event.client_payload.ReleaseTitle }}
2018
body: ${{ github.event.client_payload.ReleaseBody }}
2119
prerelease: ${{ github.event.client_payload.Prerelease }}
2220
commit: ${{ github.event.client_payload.Commitish }}
21+
allowUpdates: true

.github/workflows/create_pull_request.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

.github/workflows/update_github_release.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ jobs:
1010
runs-on: ubuntu-latest
1111

1212
steps:
13-
- uses: actions/checkout@v4
14-
1513
- name: Update release for ${{ github.event.client_payload.ReleaseBranchName }}
1614
uses: actions/github-script@v7
1715
with:

0 commit comments

Comments
 (0)