Skip to content

Commit 938d0ec

Browse files
authored
Add a github actions workflow for keeping docs in sync. (#155)
Uses the claude code github actions integration (https://code.claude.com/docs/en/github-actions.md) to look at the changes to the API schema in the last day and check docs and examples for anything out of date. If it finds something that should be updated, it'll send out a PR to fix it.
1 parent e84817d commit 938d0ec

1 file changed

Lines changed: 165 additions & 0 deletions

File tree

.github/workflows/docs-sync.yml

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
name: Nightly Documentation Sync
2+
3+
on:
4+
schedule:
5+
# Run at 8AM UTC daily (12AM PST)
6+
- cron: '0 8 * * *'
7+
workflow_dispatch:
8+
inputs:
9+
hours_lookback:
10+
description: 'Hours to look back for changes (default: 24)'
11+
required: false
12+
default: '24'
13+
14+
permissions:
15+
contents: write
16+
pull-requests: write
17+
issues: write
18+
19+
jobs:
20+
detect-changes:
21+
runs-on: ubuntu-latest
22+
outputs:
23+
has_changes: ${{ steps.check.outputs.has_changes }}
24+
changed_files: ${{ steps.check.outputs.changed_files }}
25+
change_summary: ${{ steps.check.outputs.change_summary }}
26+
steps:
27+
- uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
30+
31+
- name: Check for OpenAPI changes
32+
id: check
33+
run: |
34+
HOURS="${{ github.event.inputs.hours_lookback || '24' }}"
35+
SINCE=$(date -u -d "${HOURS} hours ago" '+%Y-%m-%dT%H:%M:%S')
36+
37+
# Find commits touching openapi/ in the time window
38+
CHANGED_FILES=$(git log --since="$SINCE" --name-only --pretty=format: -- 'openapi/' | sort -u | grep -v '^$' || true)
39+
40+
if [ -z "$CHANGED_FILES" ]; then
41+
echo "No OpenAPI changes in the last ${HOURS} hours"
42+
echo "has_changes=false" >> $GITHUB_OUTPUT
43+
else
44+
echo "Found OpenAPI changes:"
45+
echo "$CHANGED_FILES"
46+
echo "has_changes=true" >> $GITHUB_OUTPUT
47+
48+
# Store changed files (escape newlines for GitHub output)
49+
echo "changed_files<<EOF" >> $GITHUB_OUTPUT
50+
echo "$CHANGED_FILES" >> $GITHUB_OUTPUT
51+
echo "EOF" >> $GITHUB_OUTPUT
52+
53+
# Get a summary of what changed
54+
SUMMARY=$(git log --since="$SINCE" --oneline -- 'openapi/' || true)
55+
echo "change_summary<<EOF" >> $GITHUB_OUTPUT
56+
echo "$SUMMARY" >> $GITHUB_OUTPUT
57+
echo "EOF" >> $GITHUB_OUTPUT
58+
fi
59+
60+
sync-docs:
61+
needs: detect-changes
62+
if: needs.detect-changes.outputs.has_changes == 'true'
63+
runs-on: ubuntu-latest
64+
steps:
65+
- uses: actions/checkout@v4
66+
with:
67+
fetch-depth: 0
68+
69+
- name: Setup Node.js
70+
uses: actions/setup-node@v4
71+
with:
72+
node-version: '24'
73+
cache: 'npm'
74+
75+
- name: Install dependencies
76+
run: npm ci
77+
78+
- name: Sync documentation with Claude
79+
id: claude
80+
uses: anthropics/claude-code-action@v1
81+
with:
82+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
83+
claude_args:
84+
--allowedTools Bash,Read,Write,Edit,Glob,Grep,WebFetch
85+
--model claude-opus-4-5-20251101
86+
--max-turns 30
87+
prompt: |
88+
## Task: Documentation Sync Review
89+
90+
OpenAPI schema changes were detected in the last 24 hours. Your task is to ensure all documentation is up to date with these changes.
91+
92+
### Recent Schema Changes
93+
**Commits:**
94+
${{ needs.detect-changes.outputs.change_summary }}
95+
96+
**Changed Files:**
97+
${{ needs.detect-changes.outputs.changed_files }}
98+
99+
### Review Checklist
100+
101+
1. **Understand the Changes**
102+
- Read the changed files in `openapi/` to understand what was modified
103+
- Note any new endpoints, modified request/response schemas, or removed functionality
104+
105+
2. **Check Schema Examples**
106+
- Review example requests and responses in `openapi/paths/` YAML files
107+
- Review examples in `openapi/components/schemas/` YAML files
108+
- Ensure examples match the current schema definitions
109+
110+
3. **Check Mintlify Documentation**
111+
- Scan `mintlify/` for guides and tutorials that reference the changed endpoints or schemas
112+
- Check code samples in MDX files for accuracy
113+
- Look for flow descriptions that may be outdated
114+
- Key areas to check:
115+
- `mintlify/payouts-and-b2b/` - Payouts documentation
116+
- `mintlify/ramps/` - Crypto ramp documentation
117+
- `mintlify/rewards/` - Rewards documentation
118+
- `mintlify/global-p2p/` - P2P/remittance documentation
119+
- `mintlify/snippets/` - Shared content snippets
120+
- `mintlify/platform-overview/` - Core concepts
121+
122+
4. **Check for Outdated References**
123+
- Look for hardcoded field names that may have changed
124+
- Check for endpoint paths that may have been renamed
125+
- Verify response structure descriptions match the schema
126+
127+
### Actions
128+
129+
If documentation updates are needed:
130+
1. Make the necessary changes to keep docs in sync
131+
2. Run `npm run build:openapi` if you modified any files in `openapi/`
132+
3. Create a PR with:
133+
- Branch name: `docs/sync-$(date +%Y%m%d)`
134+
- Clear title describing the sync
135+
- Description listing what was updated and why
136+
137+
If documentation is already up to date:
138+
- Output a brief summary confirming no updates needed
139+
- Do not create a PR
140+
141+
### Guidelines
142+
- Follow the documentation standards in `mintlify/CLAUDE.md`
143+
- Use snippets from `mintlify/snippets/` to avoid duplication
144+
- Keep examples consistent with actual API behavior
145+
- Do not add unnecessary comments or over-explain code
146+
147+
- name: Notify Slack on PR creation
148+
if: success() && steps.claude.outputs.pr_url
149+
uses: slackapi/slack-github-action@v2.0.0
150+
with:
151+
webhook: ${{ secrets.SLACK_WEBHOOK_ENGGRID }}
152+
webhook-type: incoming-webhook
153+
payload: |
154+
{
155+
"text": "Documentation Sync: PR Created",
156+
"blocks": [
157+
{
158+
"type": "section",
159+
"text": {
160+
"type": "mrkdwn",
161+
"text": "*Documentation Sync: PR Created*\n\nOpenAPI schema changes were detected and documentation updates have been proposed.\n\n*Pull Request:* <${{ steps.claude.outputs.pr_url }}|View PR>\n*Workflow:* <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Run>"
162+
}
163+
}
164+
]
165+
}

0 commit comments

Comments
 (0)