Skip to content

Commit db0ca73

Browse files
authored
Add detail to content pipeline auto-PRs for reviewers (#60070)
1 parent 961d188 commit db0ca73

File tree

3 files changed

+53
-12
lines changed

3 files changed

+53
-12
lines changed

.github/workflows/content-pipelines.yml

Lines changed: 34 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ jobs:
9191
fi
9292
9393
- name: Run content pipeline update script
94+
id: update
9495
env:
9596
GH_TOKEN: ${{ secrets.DOCS_BOT_PAT_BASE }}
9697
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -133,27 +134,48 @@ jobs:
133134
GH_TOKEN: ${{ secrets.DOCS_BOT_PAT_BASE }}
134135
UPDATE_BRANCH: ${{ steps.branch.outputs.update_branch }}
135136
PIPELINE_ID: ${{ matrix.id }}
137+
COMPARE_URL: ${{ steps.update.outputs.compare_url }}
138+
SHORT_RANGE: ${{ steps.update.outputs.short_range }}
136139
run: |
137140
PR_NUMBER="${{ steps.check-pr.outputs.pr_number }}"
138141
PR_TITLE="docs: update ${PIPELINE_ID} content from source docs"
139-
140-
PR_BODY="_GitHub Copilot generated this pull request._"$'\n\n'
141-
PR_BODY+="> [!NOTE]"$'\n'
142-
PR_BODY+="> This PR is **automatically generated** by the [content pipeline update workflow](${{ github.server_url }}/${{ github.repository }}/actions/workflows/content-pipelines.yml). Each run adds a new commit with any documentation changes detected."$'\n\n'
143-
PR_BODY+="## What this does"$'\n\n'
144-
PR_BODY+="Runs the \`content-pipeline-update\` agent (${PIPELINE_ID}) against the latest source docs and updates official articles under \`content/\` that have fallen out of sync."$'\n\n'
145-
PR_BODY+="## Review"$'\n\n'
146-
PR_BODY+="* Review each commit for accuracy — the agent uses AI, so spot-check important changes"$'\n'
147-
PR_BODY+="* To adjust agent behavior, see [Modifying results](${{ github.server_url }}/${{ github.repository }}/blob/main/src/content-pipelines/README.md#modifying-results)"$'\n'
148-
PR_BODY+="* Once satisfied, merge to keep docs up to date"$'\n'
149-
PR_BODY+="* A new PR will be created on the next run if there are further changes"
142+
NEW_ITEM="* [\`${SHORT_RANGE}\`](${COMPARE_URL})"
150143
151144
if [ -n "$PR_NUMBER" ]; then
152-
echo "PR #$PR_NUMBER already exists — new commit pushed"
145+
echo "PR #$PR_NUMBER already exists — appending source changes to body"
146+
147+
EXISTING_BODY=$(gh pr view "$PR_NUMBER" --json body --jq '.body')
148+
149+
# Append a new bullet before the SOURCE_CHANGES end marker
150+
# Uses bash parameter expansion for safe literal string replacement
151+
MARKER="<!-- /SOURCE_CHANGES -->"
152+
INSERTION="${NEW_ITEM}"$'\n'
153+
INSERTION+="${MARKER}"
154+
UPDATED_BODY="${EXISTING_BODY/$MARKER/$INSERTION}"
155+
156+
gh pr edit "$PR_NUMBER" --body "$UPDATED_BODY"
157+
153158
echo "Ensuring PR #$PR_NUMBER is marked ready for review"
154159
gh pr ready "$PR_NUMBER" || echo "Unable to mark PR #$PR_NUMBER as ready (it may already be ready)"
155160
else
156161
echo "Creating new PR"
162+
163+
PR_BODY="_GitHub Copilot generated this pull request._"$'\n\n'
164+
PR_BODY+="> [!NOTE]"$'\n'
165+
PR_BODY+="> This PR is **automatically generated** by the [content pipeline update workflow](${{ github.server_url }}/${{ github.repository }}/actions/workflows/content-pipelines.yml). Each run adds a new commit with any documentation changes detected."$'\n\n'
166+
PR_BODY+="## What this does"$'\n\n'
167+
PR_BODY+="Runs the \`content-pipeline-update\` agent (${PIPELINE_ID}) against the latest source docs and updates official articles under \`content/\` that have fallen out of sync."$'\n\n'
168+
PR_BODY+="## Source changes"$'\n\n'
169+
PR_BODY+="Changes in the source repo that triggered this update:"$'\n\n'
170+
PR_BODY+="<!-- SOURCE_CHANGES -->"$'\n'
171+
PR_BODY+="${NEW_ITEM}"$'\n'
172+
PR_BODY+="<!-- /SOURCE_CHANGES -->"$'\n\n'
173+
PR_BODY+="## Review"$'\n\n'
174+
PR_BODY+="* Review each commit for accuracy — the agent uses AI, so spot-check important changes"$'\n'
175+
PR_BODY+="* To adjust agent behavior, see [Modifying results](${{ github.server_url }}/${{ github.repository }}/blob/main/src/content-pipelines/README.md#modifying-results)"$'\n'
176+
PR_BODY+="* Once satisfied, merge to keep docs up to date"$'\n'
177+
PR_BODY+="* A new PR will be created on the next run if there are further changes"
178+
157179
gh pr create \
158180
--title "$PR_TITLE" \
159181
--body "$PR_BODY" \

.github/workflows/reviewers-docs-engineering.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ on:
2121
- 'src/**'
2222
- '!src/**.json' # So that Docs Engineering isn't reviewing automated pipeline data PRs
2323
- '!src/**.yml' # So that Docs Engineering isn't reviewing automated pipeline data PRs
24+
- '!src/**.sha' # So that Docs Engineering isn't reviewing automated pipeline data PRs
2425
- '.github/**'
2526
- 'config/**'
2627
- '.devcontainer/**'

src/content-pipelines/scripts/update.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,24 @@ async function main(): Promise<void> {
324324
fs.writeFileSync(SHA_FILE, `${currentSha}\n`)
325325
console.log(`\nUpdated ${SHA_FILE} to ${currentSha}`)
326326
}
327+
328+
// ---- Write source change metadata to $GITHUB_OUTPUT ----
329+
// The workflow uses these values to populate the PR body with reviewer breadcrumbs.
330+
const ghOutput = process.env.GITHUB_OUTPUT
331+
if (ghOutput) {
332+
const compareUrl = storedSha
333+
? `https://github.com/${SOURCE_REPO}/compare/${storedSha}...${currentSha}`
334+
: `https://github.com/${SOURCE_REPO}/commit/${currentSha}`
335+
const shortRange = storedSha
336+
? `${storedSha.slice(0, 7)}...${currentSha.slice(0, 7)}`
337+
: currentSha.slice(0, 7)
338+
339+
const outputLines = [`compare_url=${compareUrl}`, `short_range=${shortRange}`]
340+
341+
fs.appendFileSync(ghOutput, `${outputLines.join('\n')}\n`)
342+
console.log('Wrote source change metadata to $GITHUB_OUTPUT')
343+
}
344+
327345
console.log('Done.')
328346
}
329347

0 commit comments

Comments
 (0)