File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -72,21 +72,31 @@ jobs:
7272 # Push the branch
7373 git push origin $BRANCH_NAME
7474
75- # Create PR using GitHub CLI
76- gh pr create \
77- --title "chore(release): ${VERSION}" \
78- --body "Automated release PR for version ${VERSION}
75+ PR_TITLE="chore(release): ${VERSION}"
76+ PR_BODY="Automated release PR for version ${VERSION}
7977
8078 This PR contains:
8179 - Updated package.json version
8280 - Updated yarn.lock (if changed)
8381 - Updated CHANGELOG.md
8482
85- Please review and merge to complete the release process." \
86- --head $BRANCH_NAME \
87- --base master
88-
89- echo "Created PR for release ${VERSION}"
83+ Please review and merge to complete the release process."
84+
85+ EXISTING_PR_URL=$(gh api "repos/${{ github.repository }}/pulls?head=${{ github.repository_owner }}:${BRANCH_NAME}&base=master&state=open" --jq '.[0].html_url // empty')
86+
87+ if [[ -n "$EXISTING_PR_URL" ]]; then
88+ echo "Release PR already exists: ${EXISTING_PR_URL}"
89+ else
90+ gh api \
91+ --method POST \
92+ "repos/${{ github.repository }}/pulls" \
93+ -f title="$PR_TITLE" \
94+ -f body="$PR_BODY" \
95+ -f head="$BRANCH_NAME" \
96+ -f base="master" \
97+ --jq '.html_url'
98+ echo "Created PR for release ${VERSION}"
99+ fi
90100 else
91101 echo "No changes to commit after staging files"
92102 git checkout master
You can’t perform that action at this time.
0 commit comments