Sync docs from BoxLite SDK #1261
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Sync docs from BoxLite SDK | |
| on: | |
| schedule: | |
| # Every 30 minutes | |
| - cron: "*/30 * * * *" | |
| workflow_dispatch: # Allow manual trigger | |
| jobs: | |
| check-and-sync: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - name: Checkout documentation repo | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Find unprocessed merged PRs | |
| id: find-pr | |
| env: | |
| GH_TOKEN: ${{ secrets.GH_PAT }} | |
| run: | | |
| # Fetch recently merged PRs from boxlite (last 20) | |
| MERGED_PRS=$(gh api "repos/boxlite-ai/boxlite/pulls?state=closed&sort=updated&direction=desc&per_page=20" \ | |
| --jq '[.[] | select(.merged_at != null) | {number, title, html_url, user: .user.login}]') | |
| # Check each PR to see if we already have a branch for it | |
| FOUND="false" | |
| for PR_NUMBER in $(echo "$MERGED_PRS" | jq -r '.[].number'); do | |
| BRANCH="docs-sync/boxlite-pr-${PR_NUMBER}" | |
| if ! git ls-remote --heads origin "$BRANCH" | grep -q "$BRANCH"; then | |
| # Also check if a PR already exists for this branch | |
| EXISTING_PR=$(gh pr list --head "$BRANCH" --state all --json number --jq 'length') | |
| if [ "$EXISTING_PR" = "0" ]; then | |
| PR_TITLE=$(echo "$MERGED_PRS" | jq -r ".[] | select(.number == ${PR_NUMBER}) | .title") | |
| PR_URL=$(echo "$MERGED_PRS" | jq -r ".[] | select(.number == ${PR_NUMBER}) | .html_url") | |
| PR_AUTHOR=$(echo "$MERGED_PRS" | jq -r ".[] | select(.number == ${PR_NUMBER}) | .user") | |
| echo "pr_number=$PR_NUMBER" >> "$GITHUB_OUTPUT" | |
| echo "pr_title=$PR_TITLE" >> "$GITHUB_OUTPUT" | |
| echo "pr_url=$PR_URL" >> "$GITHUB_OUTPUT" | |
| echo "pr_author=$PR_AUTHOR" >> "$GITHUB_OUTPUT" | |
| echo "found=true" >> "$GITHUB_OUTPUT" | |
| FOUND="true" | |
| echo "Found unprocessed PR: #${PR_NUMBER} - ${PR_TITLE}" | |
| break | |
| fi | |
| fi | |
| done | |
| if [ "$FOUND" = "false" ]; then | |
| echo "found=false" >> "$GITHUB_OUTPUT" | |
| echo "No unprocessed PRs found" | |
| fi | |
| - name: Fetch PR details | |
| if: steps.find-pr.outputs.found == 'true' | |
| id: pr-info | |
| env: | |
| GH_TOKEN: ${{ secrets.GH_PAT }} | |
| run: | | |
| PR_NUMBER="${{ steps.find-pr.outputs.pr_number }}" | |
| # Fetch the PR diff | |
| gh api "repos/boxlite-ai/boxlite/pulls/${PR_NUMBER}" \ | |
| -H "Accept: application/vnd.github.diff" \ | |
| > /tmp/pr_diff.txt | |
| # Fetch changed files list | |
| gh api "repos/boxlite-ai/boxlite/pulls/${PR_NUMBER}/files" \ | |
| --jq '.[].filename' \ | |
| > /tmp/changed_files.txt | |
| # Fetch CHANGELOG if it exists | |
| gh api "repos/boxlite-ai/boxlite/contents/CHANGELOG.md" \ | |
| -H "Accept: application/vnd.github.raw+json" \ | |
| > /tmp/changelog.md 2>/dev/null || echo "No CHANGELOG found" > /tmp/changelog.md | |
| # Fetch PR body | |
| gh api "repos/boxlite-ai/boxlite/pulls/${PR_NUMBER}" \ | |
| --jq '.body // "No description provided"' \ | |
| > /tmp/pr_body.txt | |
| - name: Run Claude Code Action | |
| if: steps.find-pr.outputs.found == 'true' | |
| uses: anthropics/claude-code-action@v1 | |
| with: | |
| anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} | |
| github_token: ${{ secrets.GH_PAT }} | |
| direct_prompt: | | |
| You are updating the BoxLite documentation site based on changes merged in the BoxLite SDK repository. | |
| ## Source PR | |
| - **PR #${{ steps.find-pr.outputs.pr_number }}**: ${{ steps.find-pr.outputs.pr_title }} | |
| - **Author**: ${{ steps.find-pr.outputs.pr_author }} | |
| - **URL**: ${{ steps.find-pr.outputs.pr_url }} | |
| ## PR Description | |
| $(cat /tmp/pr_body.txt) | |
| ## Changed Files | |
| $(cat /tmp/changed_files.txt) | |
| ## PR Diff | |
| $(head -c 50000 /tmp/pr_diff.txt) | |
| ## CHANGELOG (latest entries) | |
| $(head -200 /tmp/changelog.md) | |
| ## Your Task | |
| 1. Read the CLAUDE.md and AGENTS.md files in this repo for conventions and mapping rules. | |
| 2. Analyze the PR diff and changed files to determine what documentation needs updating. | |
| 3. Follow the source-to-docs mapping in AGENTS.md to identify which doc pages to update. | |
| 4. Apply the decision framework from AGENTS.md — skip internal refactoring, update for API changes/new features/behavior changes. | |
| 5. Make the documentation changes following all writing conventions in CLAUDE.md. | |
| 6. Do NOT add version numbers anywhere in the docs. | |
| 7. If no documentation changes are needed, create a PR explaining why and what was evaluated. | |
| Create a branch named `docs-sync/boxlite-pr-${{ steps.find-pr.outputs.pr_number }}` and commit your changes. | |
| branch: "docs-sync/boxlite-pr-${{ steps.find-pr.outputs.pr_number }}" | |
| create_pr: true | |
| pr_title: "docs: sync from boxlite PR #${{ steps.find-pr.outputs.pr_number }}" | |
| pr_body: | | |
| Automated documentation update triggered by [boxlite PR #${{ steps.find-pr.outputs.pr_number }}](${{ steps.find-pr.outputs.pr_url }}). | |
| **Source PR**: ${{ steps.find-pr.outputs.pr_title }} by @${{ steps.find-pr.outputs.pr_author }} | |
| --- | |
| *This PR was created automatically by the docs sync workflow. Please review the changes before merging.* |