Generate Documentation Suggestions #2
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: Generate Documentation Suggestions | |
| on: | |
| schedule: | |
| # Run nightly at 2 AM UTC | |
| - cron: '0 2 * * *' | |
| workflow_dispatch: | |
| inputs: | |
| lookback_days: | |
| description: 'Number of days to look back for changes' | |
| default: '7' | |
| type: string | |
| jobs: | |
| generate: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - name: Checkout dev-rel | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| cache-dependency-path: tooling/doc-suggestions/package-lock.json | |
| - name: Install dependencies | |
| working-directory: tooling/doc-suggestions | |
| run: npm install | |
| - name: Generate suggestions report | |
| working-directory: tooling/doc-suggestions | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} | |
| LOOKBACK_DAYS: ${{ inputs.lookback_days || '7' }} | |
| run: npx tsx src/index.ts | |
| - name: Upload report as artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: doc-suggestions-${{ github.run_id }} | |
| path: tooling/doc-suggestions/reports/ | |
| retention-days: 30 | |
| - name: Create PR with report | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # Check if latest.md exists and has content | |
| if [ ! -f tooling/doc-suggestions/reports/latest.md ]; then | |
| echo "No report generated" | |
| exit 0 | |
| fi | |
| DATE=$(date +%Y-%m-%d) | |
| BRANCH_NAME="docs/suggestions-${DATE}" | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| # Create new branch | |
| git checkout -b "$BRANCH_NAME" | |
| # Copy to dated report in repo root reports directory | |
| mkdir -p reports | |
| cp tooling/doc-suggestions/reports/latest.md "reports/doc-suggestions-${DATE}.md" | |
| # Stage changes | |
| git add reports/ | |
| git add tooling/doc-suggestions/reports/ | |
| # Only proceed if there are changes | |
| if git diff --staged --quiet; then | |
| echo "No changes to commit" | |
| exit 0 | |
| fi | |
| git commit -m "docs: Add documentation suggestions for ${DATE}" | |
| git push -u origin "$BRANCH_NAME" | |
| # Count suggestions by priority | |
| HIGH=$(grep -c "^### High Priority" "reports/doc-suggestions-${DATE}.md" || echo "0") | |
| MEDIUM=$(grep -c "^### Medium Priority" "reports/doc-suggestions-${DATE}.md" || echo "0") | |
| LOW=$(grep -c "^### Low Priority" "reports/doc-suggestions-${DATE}.md" || echo "0") | |
| # Create PR and request review from DevRel team | |
| gh pr create \ | |
| --title "docs: Documentation suggestions for ${DATE}" \ | |
| --body "## Documentation Update Suggestions | |
| This PR contains automatically generated suggestions for documentation updates based on recent source code changes in aztec-packages. | |
| **Review the report**: \`reports/doc-suggestions-${DATE}.md\` | |
| ### How to use | |
| 1. Review the suggestions in the report | |
| 2. For items to address, copy the relevant section | |
| 3. Open Claude Code in aztec-packages and paste the suggestion | |
| --- | |
| 🤖 Generated by the doc-suggestions tool" \ | |
| --reviewer "AztecProtocol/devrel" |