Skip to content

Commit 3ce0264

Browse files
KyleAMathewsclaude
andauthored
Remove check-docs CI & replace with a daily CI run (#806)
* ci: replace docs check with daily sync workflow - Remove check-docs job from PR workflow that was causing frequent failures due to subtle differences between local and CI doc generation - Add new daily scheduled workflow that: - Runs docs generation at 2 AM UTC daily - Automatically creates a PR if changes are detected - Updates existing PR (docs/auto-generate branch) if one already exists - Can also be triggered manually via workflow_dispatch This improves the PR experience by not blocking PRs on doc generation issues, while ensuring docs stay in sync through automated daily updates. * fix: correct YAML syntax in docs-sync workflow * feat: generate and commit docs during release workflow Docs will now be automatically generated and committed as part of the release process, ensuring they're always in sync with releases. --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent b1db2da commit 3ce0264

File tree

3 files changed

+117
-28
lines changed

3 files changed

+117
-28
lines changed

.github/workflows/docs-sync.yml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: Sync Generated Docs
2+
3+
on:
4+
schedule:
5+
# Run daily at 2 AM UTC
6+
- cron: "0 2 * * *"
7+
8+
# Allows you to run this workflow manually from the Actions tab
9+
workflow_dispatch:
10+
11+
permissions:
12+
contents: write
13+
pull-requests: write
14+
15+
jobs:
16+
sync-docs:
17+
name: Generate and Sync Docs
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v5.0.0
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Setup Tools
26+
uses: tanstack/config/.github/setup@main
27+
28+
- name: Build Packages
29+
run: pnpm run build
30+
31+
- name: Generate Docs
32+
run: pnpm docs:generate
33+
34+
- name: Check for changes
35+
id: check_changes
36+
run: |
37+
if [ -n "$(git status --porcelain)" ]; then
38+
echo "has_changes=true" >> $GITHUB_OUTPUT
39+
echo "Changes detected in generated docs"
40+
else
41+
echo "has_changes=false" >> $GITHUB_OUTPUT
42+
echo "No changes in generated docs"
43+
fi
44+
45+
- name: Configure Git
46+
if: steps.check_changes.outputs.has_changes == 'true'
47+
run: |
48+
git config user.name "github-actions[bot]"
49+
git config user.email "github-actions[bot]@users.noreply.github.com"
50+
51+
- name: Commit and Push Changes
52+
if: steps.check_changes.outputs.has_changes == 'true'
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
run: |
56+
BRANCH_NAME="docs/auto-generate"
57+
58+
# Check if branch exists remotely
59+
if git ls-remote --exit-code --heads origin $BRANCH_NAME; then
60+
echo "Branch exists, checking out and updating"
61+
git fetch origin $BRANCH_NAME
62+
git checkout $BRANCH_NAME
63+
git pull origin $BRANCH_NAME
64+
else
65+
echo "Creating new branch"
66+
git checkout -b $BRANCH_NAME
67+
fi
68+
69+
# Stage and commit changes
70+
git add docs/
71+
git commit -m "docs: regenerate API documentation
72+
73+
Auto-generated by daily docs sync workflow"
74+
75+
# Push changes
76+
git push origin $BRANCH_NAME
77+
78+
- name: Create or Update PR
79+
if: steps.check_changes.outputs.has_changes == 'true'
80+
env:
81+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82+
run: |
83+
BRANCH_NAME="docs/auto-generate"
84+
85+
# Check if PR already exists
86+
existing_pr=$(gh pr list --head $BRANCH_NAME --json number --jq '.[0].number')
87+
88+
if [ -n "$existing_pr" ]; then
89+
echo "PR #$existing_pr already exists, it has been updated with the latest changes"
90+
gh pr comment $existing_pr --body "Updated with latest generated docs from scheduled workflow run."
91+
else
92+
echo "Creating new PR"
93+
gh pr create \
94+
--title "docs: sync generated API documentation" \
95+
--body "This PR was automatically created by the daily docs sync workflow.
96+
97+
The generated API documentation has been updated to reflect the latest changes in the codebase.
98+
99+
**Generated by**: [Docs Sync Workflow](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
100+
101+
Please review and merge if the changes look correct." \
102+
--head $BRANCH_NAME \
103+
--base main
104+
fi

.github/workflows/pr.yml

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -90,31 +90,3 @@ jobs:
9090
run: |
9191
cd examples/react/projects
9292
pnpm build
93-
check-docs:
94-
name: Check Generated Docs
95-
runs-on: ubuntu-latest
96-
steps:
97-
- name: Checkout
98-
uses: actions/checkout@v5.0.0
99-
- name: Setup Tools
100-
uses: tanstack/config/.github/setup@main
101-
- name: Build Packages
102-
run: pnpm run build
103-
- name: Generate Docs
104-
run: pnpm docs:generate
105-
- name: Check for changes
106-
run: |
107-
if [ -n "$(git status --porcelain)" ]; then
108-
echo "Error: Generated docs are out of sync!"
109-
echo ""
110-
echo "Please run the following commands locally and commit the changes:"
111-
echo " 1. pnpm install"
112-
echo " 2. pnpm build"
113-
echo " 3. pnpm docs:generate"
114-
echo " 4. git add docs/"
115-
echo " 5. git commit -m 'docs: regenerate API documentation'"
116-
echo ""
117-
echo "Files that need to be updated:"
118-
git status --short
119-
exit 1
120-
fi

.github/workflows/release.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@ jobs:
3030
uses: tanstack/config/.github/setup@main
3131
- name: Run Tests
3232
run: pnpm run lint && pnpm run build && pnpm run test
33+
- name: Generate Docs
34+
run: pnpm docs:generate
35+
- name: Commit Generated Docs
36+
run: |
37+
if [ -n "$(git status --porcelain)" ]; then
38+
git config user.name "github-actions[bot]"
39+
git config user.email "github-actions[bot]@users.noreply.github.com"
40+
git add docs/
41+
git commit -m "docs: regenerate API documentation"
42+
git push
43+
else
44+
echo "No changes in generated docs"
45+
fi
3346
- name: Run Changesets (version or publish)
3447
id: changesets
3548
uses: changesets/action@v1.5.3

0 commit comments

Comments
 (0)