File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -105,14 +105,22 @@ jobs:
105105 > **Reviewer:** Please close and reopen this PR to trigger CI checks.
106106 > See: https://docs.github.com/en/actions/how-tos/write-workflows/choose-when-workflows-run/trigger-a-workflow#triggering-a-workflow-from-a-workflow
107107 run : |
108- # Check for existing PR from this branch
109- EXISTING_PR=$(gh pr list --state open --head "$BRANCH_NAME" --json url --jq ".[0].url")
108+ # Check for existing open PR from this branch
109+ EXISTING_PR=$(gh pr list --state open --head "$BRANCH_NAME" --json url --jq ".[0].url // empty ")
110110
111111 if [ -n "$EXISTING_PR" ]; then
112112 echo "Updating existing PR: $EXISTING_PR" >> "$GITHUB_STEP_SUMMARY"
113113 git push -u origin "$BRANCH_NAME" --force
114114 gh pr edit "$EXISTING_PR" --title "$PR_TITLE" --body "$PR_BODY"
115115 else
116+ # Check if a closed PR with the same title already exists
117+ CLOSED_PR=$(gh pr list --state closed --search "$PR_TITLE in:title" --json url --jq ".[0].url // empty")
118+ if [ -n "$CLOSED_PR" ]; then
119+ echo "A closed PR already exists for this version: $CLOSED_PR" >> "$GITHUB_STEP_SUMMARY"
120+ echo "Skipping PR creation."
121+ exit 0
122+ fi
123+
116124 echo "Creating new PR" >> "$GITHUB_STEP_SUMMARY"
117125 git push -u origin "$BRANCH_NAME"
118126 gh pr create \
You can’t perform that action at this time.
0 commit comments