Skip to content

Generate Documentation Suggestions #9

Generate Documentation Suggestions

Generate Documentation Suggestions #9

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: Push branch and create issue
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"
# Create issue with link to create PR (org settings prevent Actions from creating PRs directly)
gh issue create \
--title "📚 Documentation suggestions ready for ${DATE}" \
--body "## Documentation Update Suggestions
New suggestions have been generated based on recent source code changes in aztec-packages.
### 👉 [Click here to create the PR](https://github.com/${{ github.repository }}/compare/main...${BRANCH_NAME}?expand=1)
**Branch**: \`${BRANCH_NAME}\`
**Report**: \`reports/doc-suggestions-${DATE}.md\`
### How to use
1. Click the link above to create a PR from the branch
2. Review the suggestions in the report
3. For items to address, copy the relevant section
4. Open Claude Code in aztec-packages and paste the suggestion
---
🤖 Generated by the doc-suggestions tool"