Skip to content

Commit a5cfe36

Browse files
heiskrCopilot
andauthored
Guard llms.txt sync commit against empty diff (#62096)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 3990960 commit a5cfe36

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,17 @@ jobs:
105105
git config user.name "docs-bot"
106106
git config user.email "77750099+docs-bot@users.noreply.github.com"
107107
git add data/llms-txt/docs.md
108-
git commit -m "Update data/llms-txt/docs.md from popularity data"
109-
git push "https://x-access-token:${GH_TOKEN}@github.com/github/docs-internal.git" "$BRANCH"
108+
# diff_docs compares against main, but the sync branch may already
109+
# exist with this exact content (open PR from a prior run). In that
110+
# case there is nothing new to stage, and `git commit` would exit 1
111+
# and fail the whole workflow. Skip the commit and push when the
112+
# branch is already up to date.
113+
if git diff --cached --quiet; then
114+
echo "Sync branch already has the latest generated docs.md; nothing to commit."
115+
else
116+
git commit -m "Update data/llms-txt/docs.md from popularity data"
117+
git push "https://x-access-token:${GH_TOKEN}@github.com/github/docs-internal.git" "$BRANCH"
118+
fi
110119
111120
- name: Create or update docs-internal PR
112121
if: steps.diff_docs.outputs.changed == 'true'

0 commit comments

Comments
 (0)