Skip to content

Commit a27486e

Browse files
Sync llms-full.txt as a static duplicate (#62864)
Co-authored-by: Natalie Harris <natalierharris@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 55c15fb commit a27486e

1 file changed

Lines changed: 65 additions & 37 deletions

File tree

.github/workflows/sync-llms-txt.yml

Lines changed: 65 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
name: Sync llms.txt
22

3-
# **What it does**: Generates docs.github.com/llms.txt and github.com/llms.txt
4-
# from the page catalog and popularity data, then opens PRs to update both.
3+
# **What it does**: Generates docs.github.com/llms.txt, github.com/llms.txt, and
4+
# github.com/llms-full.txt from the page catalog and popularity data, then
5+
# opens PRs to update them.
56
# **Why we have it**: Agents discover docs through llms.txt; the page list keeps
67
# pace with what's actually popular without writers updating it by hand.
78
# **Who does it impact**: Docs consumers via agents, and anyone landing on
8-
# github.com/llms.txt or docs.github.com/llms.txt.
9+
# github.com/llms.txt, github.com/llms-full.txt, or docs.github.com/llms.txt.
910

1011
on:
1112
workflow_dispatch:
@@ -134,24 +135,34 @@ jobs:
134135
--draft \
135136
--label "llm-generated"
136137
137-
# ---------- PR to github/github: update public/llms.txt ----------
138+
# ---------- PR to github/github: update public/llms*.txt ----------
138139

139-
- name: Fetch current public/llms.txt from github/github
140+
- name: Fetch current public llms files from github/github
140141
id: fetch_monolith
141142
env:
142143
GH_TOKEN: ${{ secrets.DOCS_BOT_PAT_BASE }}
143144
run: |
144-
if gh api repos/github/github/contents/public/llms.txt \
145-
--jq '.content' 2>/dev/null | base64 -d > /tmp/monolith-current.txt; then
146-
echo "Fetched current ($(wc -l < /tmp/monolith-current.txt) lines)"
147-
else
148-
rm -f /tmp/monolith-current.txt
149-
fi
145+
fetch_current() {
146+
local target_file="$1"
147+
local output_file="$2"
148+
if gh api -H "Accept: application/vnd.github.raw" \
149+
"repos/github/github/contents/$target_file" \
150+
> "$output_file" 2>/dev/null; then
151+
echo "Fetched current $target_file"
152+
else
153+
rm -f "$output_file"
154+
fi
155+
}
156+
fetch_current public/llms.txt /tmp/monolith-current-llms.txt
157+
fetch_current public/llms-full.txt /tmp/monolith-current-llms-full.txt
150158
151-
- name: Diff monolith llms.txt
159+
- name: Diff monolith llms files
152160
id: diff_monolith
153161
run: |
154-
if [ -f /tmp/monolith-current.txt ] && diff -q /tmp/monolith-llms.txt /tmp/monolith-current.txt > /dev/null 2>&1; then
162+
if [ -f /tmp/monolith-current-llms.txt ] && \
163+
diff -q /tmp/monolith-llms.txt /tmp/monolith-current-llms.txt > /dev/null 2>&1 && \
164+
[ -f /tmp/monolith-current-llms-full.txt ] && \
165+
diff -q /tmp/monolith-llms.txt /tmp/monolith-current-llms-full.txt > /dev/null 2>&1; then
155166
echo "No monolith changes, skipping"
156167
echo "changed=false" >> "$GITHUB_OUTPUT"
157168
else
@@ -177,49 +188,56 @@ jobs:
177188
echo "Created branch $BRANCH from $DEFAULT_BRANCH at $BASE_SHA"
178189
fi
179190
180-
- name: Commit monolith llms.txt to github/github
191+
- name: Commit monolith llms files to github/github
181192
if: steps.diff_monolith.outputs.changed == 'true'
182193
env:
183194
GH_TOKEN: ${{ secrets.DOCS_BOT_PAT_BASE }}
184195
run: |
185196
REPO="github/github"
186197
CONTENT=$(base64 -w 0 /tmp/monolith-llms.txt)
187198
188-
if EXISTING_SHA=$(gh api "repos/$REPO/contents/public/llms.txt?ref=$BRANCH" \
189-
--jq '.sha' 2>/dev/null); then
190-
echo "Existing file SHA: $EXISTING_SHA"
191-
else
192-
EXISTING_SHA=""
193-
fi
199+
sync_file() {
200+
local target_file="$1"
201+
local branch_copy="/tmp/monolith-branch-$(basename "$target_file")"
202+
if gh api -H "Accept: application/vnd.github.raw" \
203+
"repos/$REPO/contents/$target_file?ref=$BRANCH" \
204+
> "$branch_copy" 2>/dev/null && \
205+
diff -q /tmp/monolith-llms.txt "$branch_copy" > /dev/null 2>&1; then
206+
echo "$target_file is already current on $BRANCH"
207+
return
208+
fi
194209
195-
COMMIT_ARGS=(-f "message=Sync llms.txt from docs.github.com"
196-
-f "content=$CONTENT"
197-
-f "branch=$BRANCH")
198-
if [ -n "$EXISTING_SHA" ]; then
199-
COMMIT_ARGS+=(-f "sha=$EXISTING_SHA")
200-
fi
201-
gh api "repos/$REPO/contents/public/llms.txt" \
202-
--method PUT \
203-
"${COMMIT_ARGS[@]}" --jq '.commit.sha'
210+
local existing_sha
211+
existing_sha=$(gh api "repos/$REPO/contents/$target_file?ref=$BRANCH" \
212+
--jq '.sha' 2>/dev/null || true)
213+
local commit_args=(-f "message=Sync $(basename "$target_file") from docs.github.com"
214+
-f "content=$CONTENT"
215+
-f "branch=$BRANCH")
216+
if [ -n "$existing_sha" ]; then
217+
commit_args+=(-f "sha=$existing_sha")
218+
fi
219+
gh api "repos/$REPO/contents/$target_file" \
220+
--method PUT \
221+
"${commit_args[@]}" --jq '.commit.sha'
222+
}
223+
224+
sync_file public/llms.txt
225+
sync_file public/llms-full.txt
204226
205227
- name: Create or update github/github PR
206228
if: steps.diff_monolith.outputs.changed == 'true'
207229
env:
208230
GH_TOKEN: ${{ secrets.DOCS_BOT_PAT_BASE }}
209231
run: |
210232
REPO="github/github"
211-
if EXISTING_PR=$(gh pr list --repo "$REPO" --head "$BRANCH" \
212-
--json number --jq '.[0].number' 2>/dev/null) && [ -n "$EXISTING_PR" ]; then
213-
echo "Monolith PR #$EXISTING_PR already exists, updated with new commit"
214-
exit 0
215-
fi
216-
217233
RUN_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
218234
DEFAULT_BRANCH=$(gh api "repos/$REPO" --jq '.default_branch')
219235
220236
PR_BODY="The [sync-llms-txt workflow]($RUN_URL) generated this PR.
221237
222-
Updates \`public/llms.txt\`, served at https://github.com/llms.txt. Built in docs-internal from the page catalog and popularity data using \`data/llms-txt/config-default.yml\` + \`config-monolith.yml\`.
238+
Updates the static generated files \`public/llms.txt\` and \`public/llms-full.txt\`, served at https://github.com/llms.txt and https://github.com/llms-full.txt. Both are built in docs-internal from the page catalog and popularity data using \`data/llms-txt/config-default.yml\` + \`config-monolith.yml\`.
239+
240+
Initially, \`llms-full.txt\` is intentionally an exact duplicate of \`llms.txt\`.
223241
224242
No feature flags. Static file in \`public/\`, no code changes.
225243
@@ -233,9 +251,19 @@ jobs:
233251
pull_request_template_version=2
234252
-->"
235253
254+
if EXISTING_PR=$(gh pr list --repo "$REPO" --head "$BRANCH" \
255+
--json number --jq '.[0].number' 2>/dev/null) && [ -n "$EXISTING_PR" ]; then
256+
gh api "repos/$REPO/pulls/$EXISTING_PR" \
257+
--method PATCH \
258+
-f title="Sync llms.txt and llms-full.txt from docs.github.com" \
259+
-f body="$PR_BODY" > /dev/null
260+
echo "Monolith PR #$EXISTING_PR already exists, updated with new commit"
261+
exit 0
262+
fi
263+
236264
gh pr create \
237265
--repo "$REPO" \
238-
--title "Sync llms.txt from docs.github.com" \
266+
--title "Sync llms.txt and llms-full.txt from docs.github.com" \
239267
--body "$PR_BODY" \
240268
--head "$BRANCH" \
241269
--base "$DEFAULT_BRANCH" \

0 commit comments

Comments
 (0)