Skip to content

Commit 906bfce

Browse files
authored
Improve the content pipeline diff link (#60147)
1 parent 6f9aa0a commit 906bfce

File tree

2 files changed

+15
-37
lines changed

2 files changed

+15
-37
lines changed

.github/workflows/content-pipelines.yml

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ jobs:
9191
fi
9292
9393
- name: Run content pipeline update script
94-
id: update
9594
env:
9695
GH_TOKEN: ${{ secrets.DOCS_BOT_PAT_BASE }}
9796
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -128,32 +127,31 @@ jobs:
128127
git push origin "$UPDATE_BRANCH"
129128
fi
130129
130+
- name: Read source repo info from config
131+
id: source-info
132+
env:
133+
PIPELINE_ID: ${{ matrix.id }}
134+
run: |
135+
SOURCE_REPO=$(yq -r ".[\"${PIPELINE_ID}\"].\"source-repo\"" src/content-pipelines/config.yml)
136+
SOURCE_PATH=$(yq -r ".[\"${PIPELINE_ID}\"].\"source-path\"" src/content-pipelines/config.yml)
137+
echo "source_repo=$SOURCE_REPO" >> "$GITHUB_OUTPUT"
138+
echo "source_path=$SOURCE_PATH" >> "$GITHUB_OUTPUT"
139+
131140
- name: Create or update PR
132141
if: steps.commit.outputs.has_changes == 'true'
133142
env:
134143
GH_TOKEN: ${{ secrets.DOCS_BOT_PAT_BASE }}
135144
UPDATE_BRANCH: ${{ steps.branch.outputs.update_branch }}
136145
PIPELINE_ID: ${{ matrix.id }}
137-
COMPARE_URL: ${{ steps.update.outputs.compare_url }}
138-
SHORT_RANGE: ${{ steps.update.outputs.short_range }}
146+
SOURCE_REPO: ${{ steps.source-info.outputs.source_repo }}
147+
SOURCE_PATH: ${{ steps.source-info.outputs.source_path }}
139148
run: |
140149
PR_NUMBER="${{ steps.check-pr.outputs.pr_number }}"
141150
PR_TITLE="docs: update ${PIPELINE_ID} content from source docs"
142-
NEW_ITEM="* [\`${SHORT_RANGE}\`](${COMPARE_URL})"
151+
SOURCE_LINK="See the [upstream repo](https://github.com/${SOURCE_REPO}/tree/main/${SOURCE_PATH}) for changes that triggered this update."
143152
144153
if [ -n "$PR_NUMBER" ]; then
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"
154+
echo "PR #$PR_NUMBER already exists"
157155
158156
echo "Ensuring PR #$PR_NUMBER is marked ready for review"
159157
gh pr ready "$PR_NUMBER" || echo "Unable to mark PR #$PR_NUMBER as ready (it may already be ready)"
@@ -166,10 +164,7 @@ jobs:
166164
PR_BODY+="## What this does"$'\n\n'
167165
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'
168166
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'
167+
PR_BODY+="${SOURCE_LINK}"$'\n\n'
173168
PR_BODY+="## Review"$'\n\n'
174169
PR_BODY+="* Review each commit for accuracy — the agent uses AI, so spot-check important changes"$'\n'
175170
PR_BODY+="* To adjust agent behavior, see [Modifying results](${{ github.server_url }}/${{ github.repository }}/blob/main/src/content-pipelines/README.md#modifying-results)"$'\n'

src/content-pipelines/scripts/update.ts

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -325,23 +325,6 @@ async function main(): Promise<void> {
325325
console.log(`\nUpdated ${SHA_FILE} to ${currentSha}`)
326326
}
327327

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-
345328
console.log('Done.')
346329
}
347330

0 commit comments

Comments
 (0)