1111 required : false
1212 default : " "
1313 pull_request :
14+ paths :
15+ - ' .github/workflows/sync-cli-docs.yml'
16+ - ' hack/sync-cli-docs.sh'
1417
1518permissions :
1619 contents : write
6568 ./hack/sync-cli-docs.sh HEAD cli-source
6669 EXIT_CODE=$?
6770 set -e
68-
71+
6972 if [ $EXIT_CODE -eq 0 ]; then
7073 echo "changes=true" >> "$GITHUB_OUTPUT"
7174 echo "Changes detected - syncing CLI docs" >> "$GITHUB_STEP_SUMMARY"
@@ -87,14 +90,41 @@ jobs:
8790 if : steps.sync.outputs.changes == 'true' && github.event_name != 'pull_request'
8891 env :
8992 GH_TOKEN : ${{ github.token }}
93+ PR_TITLE : " cli: sync docs with cli ${{ steps.get-version.outputs.version }}"
9094 PR_BODY : |
9195 ## Summary
9296
9397 Automated sync of CLI documentation from docker/cli repository.
98+
99+ **CLI Version:** ${{ steps.get-version.outputs.version }}
100+
101+ ---
102+
103+ > [!IMPORTANT]
104+ > **Reviewer:** Please close and reopen this PR to trigger CI checks.
105+ > See: https://docs.github.com/en/actions/how-tos/write-workflows/choose-when-workflows-run/trigger-a-workflow#triggering-a-workflow-from-a-workflow
94106 run : |
107+ CLI_VERSION="${{ steps.get-version.outputs.version }}"
108+
109+ # Check for existing PR
110+ EXISTING_PR=$(gh pr list --state open --json title,url --jq ".[] | select(.title | contains(\"$PR_TITLE\")) | .url" | head -n 1)
111+
112+ if [ -n "$EXISTING_PR" ]; then
113+ echo "PR already exists for CLI version $CLI_VERSION" >> "$GITHUB_STEP_SUMMARY"
114+ echo "Existing PR: $EXISTING_PR" >> "$GITHUB_STEP_SUMMARY"
115+
116+ # Add a bump comment
117+ gh pr comment "$EXISTING_PR" --body "🔄 @engine PTAL"
118+ echo "Added bump comment to PR" >> "$GITHUB_STEP_SUMMARY"
119+
120+ exit 0
121+ fi
122+
123+ echo "Creating PR for CLI version $CLI_VERSION" >> "$GITHUB_STEP_SUMMARY"
124+
95125 git push -u origin "${{ steps.create-branch.outputs.branch_name }}"
96126 gh pr create \
97- --title "cli: sync docs with docker/cli " \
127+ --title "$PR_TITLE " \
98128 --body "$PR_BODY" \
99129 --base main \
100130 --head "${{ steps.create-branch.outputs.branch_name }}"
0 commit comments