Skip to content

Commit aabd3f9

Browse files
committed
gha/sync-cli-docs: Ignore explicitly closed versions
Avoid repeatedly opening new PRs for the same CLI version when a previous one was intentionally closed. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
1 parent b2745bd commit aabd3f9

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

.github/workflows/sync-cli-docs.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,22 @@ jobs:
108108
> **Reviewer:** Please close and reopen this PR to trigger CI checks.
109109
> See: https://docs.github.com/en/actions/how-tos/write-workflows/choose-when-workflows-run/trigger-a-workflow#triggering-a-workflow-from-a-workflow
110110
run: |
111-
# Check for existing PR from this branch
112-
EXISTING_PR=$(gh pr list --state open --head "$BRANCH_NAME" --json url --jq ".[0].url")
111+
# Check for existing open PR from this branch
112+
EXISTING_PR=$(gh pr list --state open --head "$BRANCH_NAME" --json url --jq ".[0].url // empty")
113113
114114
if [ -n "$EXISTING_PR" ]; then
115115
echo "Updating existing PR: $EXISTING_PR" >> "$GITHUB_STEP_SUMMARY"
116116
git push -u origin "$BRANCH_NAME" --force
117117
gh pr edit "$EXISTING_PR" --title "$PR_TITLE" --body "$PR_BODY"
118118
else
119+
# Check if a closed PR with the same title already exists
120+
CLOSED_PR=$(gh pr list --state closed --search "$PR_TITLE in:title" --json url --jq ".[0].url // empty")
121+
if [ -n "$CLOSED_PR" ]; then
122+
echo "A closed PR already exists for this version: $CLOSED_PR" >> "$GITHUB_STEP_SUMMARY"
123+
echo "Skipping PR creation."
124+
exit 0
125+
fi
126+
119127
echo "Creating new PR" >> "$GITHUB_STEP_SUMMARY"
120128
git push -u origin "$BRANCH_NAME"
121129
gh pr create \

0 commit comments

Comments
 (0)