Skip to content

Commit a0e4bf3

Browse files
evantahlergithub-actions[bot]torresmateo
authored
LLMs.txt generation on every PR (#556)
* LLMs.txt generation on every PR * small change to page * do not update if there are no changes * 🤖 Regenerate LLMs.txt * bump change * bump * 🤖 Regenerate LLMs.txt --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Mateo Torres <[email protected]>
1 parent fa9e294 commit a0e4bf3

File tree

3 files changed

+336
-41
lines changed

3 files changed

+336
-41
lines changed

.github/workflows/llmstxt.yml

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: Generate LLMs.txt
22

33
on:
4-
schedule:
5-
- cron: "0 0 * * 0" # Run at 00:00 every Sunday
64
workflow_dispatch:
5+
pull_request:
6+
types: [opened, synchronize, reopened]
77

88
permissions:
99
contents: write
@@ -27,7 +27,8 @@ jobs:
2727
- name: Checkout code
2828
uses: actions/checkout@v4
2929
with:
30-
ref: main
30+
ref: ${{ github.event.pull_request.head.ref || github.ref }}
31+
token: ${{ secrets.DOCS_PUBLISHABLE_GH_TOKEN }}
3132

3233
- name: Install dependencies
3334
run: npm install -g pnpm
@@ -40,8 +41,26 @@ jobs:
4041
env:
4142
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
4243

43-
# commit the changes and make a PR (branch protection)
44-
- name: Create Pull Request
44+
- name: Check for changes
45+
id: check-changes
46+
run: |
47+
if [ -n "$(git status --porcelain)" ]; then
48+
echo "has_changes=true" >> $GITHUB_OUTPUT
49+
else
50+
echo "has_changes=false" >> $GITHUB_OUTPUT
51+
fi
52+
53+
- name: Commit changes to PR
54+
if: steps.check-changes.outputs.has_changes == 'true' && github.event_name == 'pull_request'
55+
run: |
56+
git config user.name "github-actions[bot]"
57+
git config user.email "github-actions[bot]@users.noreply.github.com"
58+
git add public/llms.txt
59+
git commit -m "🤖 Regenerate LLMs.txt"
60+
git push
61+
62+
- name: Create Pull Request (for scheduled/manual runs)
63+
if: steps.check-changes.outputs.has_changes == 'true' && github.event_name != 'pull_request'
4564
id: cpr
4665
uses: peter-evans/create-pull-request@v7
4766
with:
@@ -55,6 +74,7 @@ jobs:
5574
torresmateo
5675
5776
- name: Enable Pull Request Automerge
77+
if: steps.check-changes.outputs.has_changes == 'true' && github.event_name != 'pull_request'
5878
run: gh pr merge --squash --auto ${{ steps.cpr.outputs.pull-request-number }}
5979
env:
6080
GH_TOKEN: ${{ secrets.DOCS_PUBLISHABLE_GH_TOKEN }}

0 commit comments

Comments
 (0)