Skip to content

Upstream Documentation Monitor #63

Upstream Documentation Monitor

Upstream Documentation Monitor #63

name: Upstream Documentation Monitor
on:
schedule:
# Run daily at 07:00 UTC (09:00 Paris time)
- cron: '0 7 * * *'
workflow_dispatch:
# Allow manual trigger from GitHub UI
permissions:
issues: write
contents: read
jobs:
check-upstream:
runs-on: ubuntu-latest
name: Check Anthropic docs for changes
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Run upstream monitor
id: monitor
run: |
python scripts/upstream_monitor.py --json --report-path docs/upstream/reports --issue-body issue_body.md > monitor_output.json 2>monitor_stderr.log || true
# Parse results
HAS_CHANGES=$(python -c "import json; d=json.load(open('monitor_output.json')); print('true' if d.get('has_changes') else 'false')")
CHANGES_COUNT=$(python -c "import json; d=json.load(open('monitor_output.json')); print(d.get('summary',{}).get('changes',0))")
NEW_COUNT=$(python -c "import json; d=json.load(open('monitor_output.json')); print(d.get('summary',{}).get('new_pages',0))")
UNREACHABLE_COUNT=$(python -c "import json; d=json.load(open('monitor_output.json')); print(d.get('summary',{}).get('unreachable',0))")
echo "has_changes=$HAS_CHANGES" >> $GITHUB_OUTPUT
echo "changes_count=$CHANGES_COUNT" >> $GITHUB_OUTPUT
echo "new_count=$NEW_COUNT" >> $GITHUB_OUTPUT
echo "unreachable_count=$UNREACHABLE_COUNT" >> $GITHUB_OUTPUT
# Surface any errors in the step summary
if [ -s monitor_stderr.log ]; then
echo "::warning::Upstream monitor stderr output detected — check logs"
fi
- name: Create or update GitHub issue
if: steps.monitor.outputs.has_changes == 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
# Check for an existing open upstream issue
EXISTING=$(gh issue list --state open --label "upstream,automated" --json number --jq '.[0].number // empty')
if [ -n "$EXISTING" ]; then
# Comment on the existing issue instead of creating a duplicate
gh issue comment "$EXISTING" \
--body "$(cat <<COMMENT_EOF
## Update — $(date -u +%Y-%m-%d)
The upstream monitor detected **${{ steps.monitor.outputs.changes_count }} update(s)** and **${{ steps.monitor.outputs.new_count }} new page(s)**.
$(cat issue_body.md | sed -n '/^### Changed Pages/,/^### Next Steps/p' | head -n -1)
---
*Appended by StoryForge Upstream Monitor (issue already open)*
COMMENT_EOF
)"
echo "Commented on existing issue #$EXISTING"
else
# No open issue — create a new one
gh issue create \
--title "Upstream docs changed: ${{ steps.monitor.outputs.changes_count }} update(s), ${{ steps.monitor.outputs.new_count }} new page(s)" \
--body-file issue_body.md \
--label "upstream,automated" \
--assignee "${{ github.repository_owner }}"
fi
- name: Summary (no changes)
if: steps.monitor.outputs.has_changes != 'true'
run: |
echo "### Upstream Monitor - No Changes" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "All ${{ steps.monitor.outputs.unreachable_count == '0' && '15' || '?' }} documentation pages checked." >> $GITHUB_STEP_SUMMARY
echo "No content changes detected. StoryForge is up to date." >> $GITHUB_STEP_SUMMARY
- name: Summary (changes detected)
if: steps.monitor.outputs.has_changes == 'true'
run: |
echo "### Upstream Monitor - Changes Detected!" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Changes**: ${{ steps.monitor.outputs.changes_count }}" >> $GITHUB_STEP_SUMMARY
echo "- **New pages**: ${{ steps.monitor.outputs.new_count }}" >> $GITHUB_STEP_SUMMARY
echo "- **Unreachable**: ${{ steps.monitor.outputs.unreachable_count }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "A GitHub issue has been created for triage." >> $GITHUB_STEP_SUMMARY