|
7 | 7 | jobs: |
8 | 8 | sync-docs: |
9 | 9 | runs-on: ubuntu-latest |
| 10 | + if: "!startsWith(github.event.pull_request.title, 'Version Packages')" |
10 | 11 | permissions: |
11 | 12 | contents: write |
12 | 13 | pull-requests: write |
@@ -155,26 +156,67 @@ jobs: |
155 | 156 | |
156 | 157 | DO NOT modify the PR_TITLE_TEXT or PR_BODY_TEXT variables. |
157 | 158 |
|
158 | | - 8. **CRITICAL - Comment on original PR (or edit existing comment):** |
159 | | - Get the docs PR URL, then create or update comment using PR_NUMBER from context: |
| 159 | + 8. **CRITICAL - Comment on original PR:** |
| 160 | + ⚠️ **IMPORTANT**: Execute this ENTIRE script as ONE command. Do not split into multiple executions. |
| 161 | + |
| 162 | + Copy and run this complete bash script: |
160 | 163 | ```bash |
| 164 | + #!/bin/bash |
| 165 | + set -e |
| 166 | + |
| 167 | + echo "=== Step 8: Managing PR comment ===" |
| 168 | + |
| 169 | + # Get the docs PR URL |
161 | 170 | DOCS_PR_URL=$(gh pr list --repo cloudflare/cloudflare-docs --head sync-docs-pr-${PR_NUMBER} --json url --jq '.[0].url') |
| 171 | + echo "Docs PR URL: $DOCS_PR_URL" |
| 172 | + |
| 173 | + # Find existing comment with our unique marker |
| 174 | + EXISTING_COMMENT_ID=$(gh api "repos/cloudflare/agents/issues/${PR_NUMBER}/comments" \ |
| 175 | + --jq '.[] | select(.body | contains("<!-- DOCS-SYNC-AUTOMATION -->")) | .id' \ |
| 176 | + | head -n 1) |
| 177 | + |
| 178 | + # Prepare comment body (note the unique marker at the start) |
| 179 | + COMMENT_BODY=\$(printf '%s\n\n%s\n\n%s' \\ |
| 180 | + '<!-- DOCS-SYNC-AUTOMATION -->' \\ |
| 181 | + "📚 **Documentation sync PR:** \$DOCS_PR_URL" \\ |
| 182 | + '_This comment is automatically updated when the PR changes._') |
162 | 183 | |
163 | | - # Check if bot comment already exists (look for unique marker) |
164 | | - EXISTING_COMMENT_ID=$(gh api repos/cloudflare/agents/issues/${PR_NUMBER}/comments --jq '.[] | select(.body | contains("docs-sync-bot-comment-marker")) | .id' | head -1) |
| 184 | + # Update existing or create new comment |
| 185 | + if [ -n "$EXISTING_COMMENT_ID" ] && [ "$EXISTING_COMMENT_ID" != "null" ]; then |
| 186 | + echo "Found existing comment ID: $EXISTING_COMMENT_ID - updating it" |
| 187 | + gh api --method PATCH \ |
| 188 | + "repos/cloudflare/agents/issues/comments/$EXISTING_COMMENT_ID" \ |
| 189 | + -f body="$COMMENT_BODY" |
| 190 | + echo "✅ Updated existing comment" |
| 191 | + else |
| 192 | + echo "No existing comment found - creating new one" |
| 193 | + gh pr comment ${PR_NUMBER} \ |
| 194 | + --repo cloudflare/agents \ |
| 195 | + --body "$COMMENT_BODY" |
| 196 | + echo "✅ Created new comment" |
| 197 | + fi |
| 198 | + |
| 199 | + # Cleanup any duplicate comments (keep only the newest) |
| 200 | + ALL_COMMENT_IDS=$(gh api "repos/cloudflare/agents/issues/${PR_NUMBER}/comments" \ |
| 201 | + --jq '.[] | select(.body | contains("<!-- DOCS-SYNC-AUTOMATION -->")) | .id') |
165 | 202 | |
166 | | - # Create comment body with proper newlines using printf |
167 | | - COMMENT_BODY=$(printf '<!-- docs-sync-bot-comment-marker -->\n\n📚 **Documentation sync PR:** %s\n\n_This comment will be updated as the PR changes._' "$DOCS_PR_URL") |
| 203 | + COMMENT_COUNT=$(echo "$ALL_COMMENT_IDS" | wc -l | tr -d ' ') |
168 | 204 | |
169 | | - if [ -n "$EXISTING_COMMENT_ID" ]; then |
170 | | - # Update existing comment |
171 | | - echo "Updating existing comment ID: $EXISTING_COMMENT_ID" |
172 | | - gh api --method PATCH /repos/cloudflare/agents/issues/comments/$EXISTING_COMMENT_ID -f body="$COMMENT_BODY" |
| 205 | + if [ "$COMMENT_COUNT" -gt 1 ]; then |
| 206 | + echo "⚠️ Found $COMMENT_COUNT duplicate comments - cleaning up" |
| 207 | + # Keep the last one (newest), delete others |
| 208 | + echo "$ALL_COMMENT_IDS" | head -n -1 | while read -r OLD_ID; do |
| 209 | + if [ -n "$OLD_ID" ]; then |
| 210 | + echo "Deleting old comment ID: $OLD_ID" |
| 211 | + gh api --method DELETE "repos/cloudflare/agents/issues/comments/$OLD_ID" |
| 212 | + fi |
| 213 | + done |
| 214 | + echo "✅ Cleaned up duplicate comments" |
173 | 215 | else |
174 | | - # Create new comment |
175 | | - echo "Creating new comment on PR #${PR_NUMBER}" |
176 | | - gh pr comment ${PR_NUMBER} --repo cloudflare/agents --body "$COMMENT_BODY" |
| 216 | + echo "✅ Only one comment exists - no cleanup needed" |
177 | 217 | fi |
| 218 | + |
| 219 | + echo "=== Step 8 complete ===" |
178 | 220 | ``` |
179 | 221 |
|
180 | 222 | ⚠️ THE TASK IS NOT COMPLETE UNTIL ALL 8 STEPS ARE DONE. Do not stop after editing files. |
@@ -205,6 +247,38 @@ jobs: |
205 | 247 | - Keep reference neutral and factual |
206 | 248 | - Don't overexplain simple functions |
207 | 249 |
|
| 250 | + ## Cloudflare Docs Style Requirements |
| 251 | +
|
| 252 | + **CRITICAL**: Follow all rules from the [Cloudflare Style Guide](https://developers.cloudflare.com/style-guide/) and these specific requirements: |
| 253 | +
|
| 254 | + **Grammar & Formatting:** |
| 255 | + - Do not use contractions, exclamation marks, or non-standard quotes like \`''""\` |
| 256 | + - Fix common spelling errors, specifically misspellings of "wrangler" |
| 257 | + - Remove whitespace characters from the end of lines |
| 258 | + - Remove duplicate words |
| 259 | + - Do not use HTML for ordered lists |
| 260 | +
|
| 261 | + **Links:** |
| 262 | + - Use full relative links (\`/agents/configuration/\`) instead of full URLs, local dev links, or dot notation |
| 263 | + - Always use trailing slashes for links without anchors |
| 264 | + - Use meaningful link words (page titles) - avoid "here", "this page", "read more" |
| 265 | + - Add cross-links to relevant documentation pages where appropriate |
| 266 | +
|
| 267 | + **Components (MUST USE):** |
| 268 | + - All components need to be imported below frontmatter: \`import { ComponentName } from "~/components";\` |
| 269 | + - **WranglerConfig component**: Replace \`toml\` or \`json\` code blocks showing Wrangler configuration with the [\`WranglerConfig\` component](https://developers.cloudflare.com/style-guide/components/wrangler-config/). This is CRITICAL - always use this component for wrangler.toml/wrangler.jsonc examples. |
| 270 | + - **DashButton component**: Replace \`https://dash.cloudflare.com\` in steps with the [\`DashButton\` component](https://developers.cloudflare.com/style-guide/components/dash-button/) |
| 271 | + - **APIRequest component**: Replace \`sh\` code blocks with API requests to \`https://api.cloudflare.com\` with the [\`APIRequest\` component](https://developers.cloudflare.com/style-guide/components/api-request/) |
| 272 | + - **FileTree component**: Replace \`txt\` blocks showing file trees with the [\`FileTree\` component](https://developers.cloudflare.com/style-guide/components/file-tree/) |
| 273 | + - **PackageManagers component**: Replace \`sh\` blocks with npm commands using the [\`PackageManagers\` component](https://developers.cloudflare.com/style-guide/components/package-managers/) |
| 274 | + - **TypeScriptExample component**: Replace \`ts\`/\`typescript\` code blocks with the [\`TypeScriptExample\` component](https://developers.cloudflare.com/style-guide/components/typescript-example/) (except in step-by-step TypeScript-specific tutorials) |
| 275 | +
|
| 276 | + **JSX & Partials:** |
| 277 | + - When using JSX fragments for conditional rendering, use props variable to account for reusability |
| 278 | + - Only use \`<Markdown />\` component in JSX conditionals, and only if needed |
| 279 | + - Do not duplicate content in ternary/binary conditions |
| 280 | + - For variables in links, use HTML instead of Markdown |
| 281 | +
|
208 | 282 | **Step 3: Provide Clear Output** |
209 | 283 |
|
210 | 284 | Clearly state your decision: |
|
0 commit comments