From e58d69c50807f97556d1f51a8339f4eb9512ba3a Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 13 Nov 2025 16:34:07 +0000 Subject: [PATCH 1/3] 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. --- .github/workflows/docs-sync.yml | 104 ++++++++++++++++++++++++++++++++ .github/workflows/pr.yml | 28 --------- 2 files changed, 104 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/docs-sync.yml diff --git a/.github/workflows/docs-sync.yml b/.github/workflows/docs-sync.yml new file mode 100644 index 000000000..c40d14a53 --- /dev/null +++ b/.github/workflows/docs-sync.yml @@ -0,0 +1,104 @@ +name: Sync Generated Docs + +on: + schedule: + # Run daily at 2 AM UTC + - cron: '0 2 * * *' + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +permissions: + contents: write + pull-requests: write + +jobs: + sync-docs: + name: Generate and Sync Docs + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v5.0.0 + with: + fetch-depth: 0 + + - name: Setup Tools + uses: tanstack/config/.github/setup@main + + - name: Build Packages + run: pnpm run build + + - name: Generate Docs + run: pnpm docs:generate + + - name: Check for changes + id: check_changes + run: | + if [ -n "$(git status --porcelain)" ]; then + echo "has_changes=true" >> $GITHUB_OUTPUT + echo "Changes detected in generated docs" + else + echo "has_changes=false" >> $GITHUB_OUTPUT + echo "No changes in generated docs" + fi + + - name: Configure Git + if: steps.check_changes.outputs.has_changes == 'true' + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + + - name: Commit and Push Changes + if: steps.check_changes.outputs.has_changes == 'true' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + BRANCH_NAME="docs/auto-generate" + + # Check if branch exists remotely + if git ls-remote --exit-code --heads origin $BRANCH_NAME; then + echo "Branch exists, checking out and updating" + git fetch origin $BRANCH_NAME + git checkout $BRANCH_NAME + git pull origin $BRANCH_NAME + else + echo "Creating new branch" + git checkout -b $BRANCH_NAME + fi + + # Stage and commit changes + git add docs/ + git commit -m "docs: regenerate API documentation + + Auto-generated by daily docs sync workflow" + + # Push changes + git push origin $BRANCH_NAME + + - name: Create or Update PR + if: steps.check_changes.outputs.has_changes == 'true' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + BRANCH_NAME="docs/auto-generate" + + # Check if PR already exists + existing_pr=$(gh pr list --head $BRANCH_NAME --json number --jq '.[0].number') + + if [ -n "$existing_pr" ]; then + echo "PR #$existing_pr already exists, it has been updated with the latest changes" + gh pr comment $existing_pr --body "Updated with latest generated docs from scheduled workflow run." + else + echo "Creating new PR" + gh pr create \ + --title "docs: sync generated API documentation" \ + --body "This PR was automatically created by the daily docs sync workflow. + +The generated API documentation has been updated to reflect the latest changes in the codebase. + +**Generated by**: [Docs Sync Workflow](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) + +Please review and merge if the changes look correct." \ + --head $BRANCH_NAME \ + --base main + fi diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 2780293be..5ff230848 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -90,31 +90,3 @@ jobs: run: | cd examples/react/projects pnpm build - check-docs: - name: Check Generated Docs - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v5.0.0 - - name: Setup Tools - uses: tanstack/config/.github/setup@main - - name: Build Packages - run: pnpm run build - - name: Generate Docs - run: pnpm docs:generate - - name: Check for changes - run: | - if [ -n "$(git status --porcelain)" ]; then - echo "Error: Generated docs are out of sync!" - echo "" - echo "Please run the following commands locally and commit the changes:" - echo " 1. pnpm install" - echo " 2. pnpm build" - echo " 3. pnpm docs:generate" - echo " 4. git add docs/" - echo " 5. git commit -m 'docs: regenerate API documentation'" - echo "" - echo "Files that need to be updated:" - git status --short - exit 1 - fi From 7767ac99f0a3ce33d6232bc7b7a451b840364527 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 13 Nov 2025 16:45:15 +0000 Subject: [PATCH 2/3] fix: correct YAML syntax in docs-sync workflow --- .github/workflows/docs-sync.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docs-sync.yml b/.github/workflows/docs-sync.yml index c40d14a53..c041168d4 100644 --- a/.github/workflows/docs-sync.yml +++ b/.github/workflows/docs-sync.yml @@ -3,7 +3,7 @@ name: Sync Generated Docs on: schedule: # Run daily at 2 AM UTC - - cron: '0 2 * * *' + - cron: "0 2 * * *" # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -94,11 +94,11 @@ jobs: --title "docs: sync generated API documentation" \ --body "This PR was automatically created by the daily docs sync workflow. -The generated API documentation has been updated to reflect the latest changes in the codebase. + The generated API documentation has been updated to reflect the latest changes in the codebase. -**Generated by**: [Docs Sync Workflow](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) + **Generated by**: [Docs Sync Workflow](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) -Please review and merge if the changes look correct." \ + Please review and merge if the changes look correct." \ --head $BRANCH_NAME \ --base main fi From 71562805d2347220079fe1be0a275e9e8def48ca Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 13 Nov 2025 16:49:23 +0000 Subject: [PATCH 3/3] 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. --- .github/workflows/release.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 155b5ae7d..6ce729857 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,6 +30,19 @@ jobs: uses: tanstack/config/.github/setup@main - name: Run Tests run: pnpm run lint && pnpm run build && pnpm run test + - name: Generate Docs + run: pnpm docs:generate + - name: Commit Generated Docs + run: | + if [ -n "$(git status --porcelain)" ]; then + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add docs/ + git commit -m "docs: regenerate API documentation" + git push + else + echo "No changes in generated docs" + fi - name: Run Changesets (version or publish) id: changesets uses: changesets/action@v1.5.3