Skip to content

Commit 5dad8f0

Browse files
committed
ci: revert doc publishing workflow changes from #980
Restore the doc publishing workflow that was removed in PR #980: - Restore docs-sync.yml for daily auto-generated docs - Restore doc generation steps in release.yml after package publish - Restore NPM_TOKEN environment variable
1 parent 2b16114 commit 5dad8f0

File tree

2 files changed

+131
-0
lines changed

2 files changed

+131
-0
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/[email protected]
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 generate-docs
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/release.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,33 @@ jobs:
4040
title: 'ci: Version Packages'
4141
env:
4242
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
44+
- name: Generate Docs
45+
if: steps.changesets.outputs.published == 'true'
46+
run: pnpm generate-docs
47+
- name: Commit Generated Docs
48+
if: steps.changesets.outputs.published == 'true'
49+
run: |
50+
if [ -n "$(git status --porcelain)" ]; then
51+
git config user.name "github-actions[bot]"
52+
git config user.email "github-actions[bot]@users.noreply.github.com"
53+
54+
BRANCH="docs/auto-update-$(date +%s)"
55+
git checkout -b "$BRANCH"
56+
git add docs/
57+
git commit -m "docs: regenerate API documentation"
58+
git push origin "$BRANCH"
59+
60+
gh pr create \
61+
--title "docs: regenerate API documentation" \
62+
--body "Automated documentation update from release" \
63+
--base main \
64+
--head "$BRANCH"
65+
else
66+
echo "No changes in generated docs"
67+
fi
68+
env:
69+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4370
- name: Comment on PRs about release
4471
if: steps.changesets.outputs.published == 'true'
4572
uses: tanstack/config/.github/comment-on-release@main

0 commit comments

Comments
 (0)