From 72d3e14405b9c7877329035ca8d80435410d67eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Fri, 2 Jan 2026 11:28:50 +0100 Subject: [PATCH 1/2] gha/sync-cli-docs: Detect existing PR MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add deduplication logic to prevent multiple PRs for the same CLI version and enhance PR management. When an existing PR is found, the workflow adds a bump comment instead of creating a duplicate. Signed-off-by: Paweł Gronowski --- .github/workflows/sync-cli-docs.yml | 31 +++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sync-cli-docs.yml b/.github/workflows/sync-cli-docs.yml index 3838cfb75d8a..220d3426bed5 100644 --- a/.github/workflows/sync-cli-docs.yml +++ b/.github/workflows/sync-cli-docs.yml @@ -65,7 +65,7 @@ jobs: ./hack/sync-cli-docs.sh HEAD cli-source EXIT_CODE=$? set -e - + if [ $EXIT_CODE -eq 0 ]; then echo "changes=true" >> "$GITHUB_OUTPUT" echo "Changes detected - syncing CLI docs" >> "$GITHUB_STEP_SUMMARY" @@ -87,14 +87,41 @@ jobs: if: steps.sync.outputs.changes == 'true' && github.event_name != 'pull_request' env: GH_TOKEN: ${{ github.token }} + PR_TITLE: "cli: sync docs with cli ${{ steps.get-version.outputs.version }}" PR_BODY: | ## Summary Automated sync of CLI documentation from docker/cli repository. + + **CLI Version:** ${{ steps.get-version.outputs.version }} + + --- + + > [!IMPORTANT] + > **Reviewer:** Please close and reopen this PR to trigger CI checks. + > See: https://docs.github.com/en/actions/how-tos/write-workflows/choose-when-workflows-run/trigger-a-workflow#triggering-a-workflow-from-a-workflow run: | + CLI_VERSION="${{ steps.get-version.outputs.version }}" + + # Check for existing PR + EXISTING_PR=$(gh pr list --state open --json title,url --jq ".[] | select(.title | contains(\"$PR_TITLE\")) | .url" | head -n 1) + + if [ -n "$EXISTING_PR" ]; then + echo "PR already exists for CLI version $CLI_VERSION" >> "$GITHUB_STEP_SUMMARY" + echo "Existing PR: $EXISTING_PR" >> "$GITHUB_STEP_SUMMARY" + + # Add a bump comment + gh pr comment "$EXISTING_PR" --body "🔄 @engine PTAL" + echo "Added bump comment to PR" >> "$GITHUB_STEP_SUMMARY" + + exit 0 + fi + + echo "Creating PR for CLI version $CLI_VERSION" >> "$GITHUB_STEP_SUMMARY" + git push -u origin "${{ steps.create-branch.outputs.branch_name }}" gh pr create \ - --title "cli: sync docs with docker/cli" \ + --title "$PR_TITLE" \ --body "$PR_BODY" \ --base main \ --head "${{ steps.create-branch.outputs.branch_name }}" From 2c6076186f85e86b8e9b270abcc8d30429c2d244 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Fri, 2 Jan 2026 11:31:35 +0100 Subject: [PATCH 2/2] gha/sync-cli-docs: Only trigger on relevant PRs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Paweł Gronowski --- .github/workflows/sync-cli-docs.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/sync-cli-docs.yml b/.github/workflows/sync-cli-docs.yml index 220d3426bed5..b6607d804958 100644 --- a/.github/workflows/sync-cli-docs.yml +++ b/.github/workflows/sync-cli-docs.yml @@ -11,6 +11,9 @@ on: required: false default: "" pull_request: + paths: + - '.github/workflows/sync-cli-docs.yml' + - 'hack/sync-cli-docs.sh' permissions: contents: write