- Create Economist SubmissionTracking package correctly: * mainArticle = full blog post content * coverLetter = 216-word SIR— letter * Links to blog post via blogPostId - Archive 'Letter to The Economist' from blog posts (it's the cover letter) - Fix date display on article cards (use published_at) - Target publication already displaying via blue badge Database changes: - Make blogPostId optional in SubmissionTracking model - Economist package ID: 68fa85ae49d4900e7f2ecd83 - Le Monde package ID: 68fa2abd2e6acd5691932150 Next: Enhanced modal with tabs, validation, export 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
8.1 KiB
Automated Public Documentation Sync - Setup Guide
Status: Implemented Last Updated: 2025-10-09 Components: GitHub Actions workflow + security validation
Overview
Automatically syncs approved documentation from the private tractatus repository to the public tractatus-framework repository with security validation.
What Gets Synced:
docs/case-studies/*.md→ Public repodocs/research/*.md→ Public repoREADME.md→ Public repo (if marked safe)
Security: All files are scanned for sensitive information before sync. Violations block the sync.
Setup Steps
1. Create GitHub Personal Access Token
- Go to GitHub → Settings → Developer settings → Personal access tokens → Tokens (classic)
- Click "Generate new token (classic)"
- Name:
Tractatus Public Sync Token - Expiration: Set appropriate expiration (90 days recommended)
- Scopes: Check
repo(Full control of private repositories) - Generate token and copy it immediately (you won't see it again)
2. Add Secret to Private Repository
- Go to
AgenticGovernance/tractatus(private repo) - Settings → Secrets and variables → Actions
- Click "New repository secret"
- Name:
PUBLIC_REPO_TOKEN - Value: Paste the PAT from step 1
- Click "Add secret"
3. (Optional) Set Up Manual Approval Environment
For sensitive changes, you can require manual approval:
- Go to
AgenticGovernance/tractatus→ Settings → Environments - Click "New environment"
- Name:
public-sync - Check "Required reviewers"
- Add yourself as a required reviewer
- Save protection rules
Note: The workflow is configured to use this environment, which creates a manual gate.
4. Test the Workflow
Automatic trigger (on push to main):
# Make a change to a case study
echo "Test update" >> docs/case-studies/test.md
git add docs/case-studies/test.md
git commit -m "docs: test automated sync"
git push origin main
Manual trigger:
- Go to Actions tab in GitHub
- Select "Sync Documentation to Public Repository"
- Click "Run workflow"
- Choose branch:
main - Skip validation:
false(recommended) - Run workflow
5. Monitor Workflow
- Go to Actions tab → Select the workflow run
- Review validation results
- If manual approval is configured, approve the deployment
- Check public repo for synced files
How It Works
Workflow Trigger
Automatic - Triggers on push to main when these paths change:
docs/case-studies/**/*.mddocs/research/**/*.mdREADME.md
Manual - Can be triggered via GitHub Actions UI with option to skip validation (use cautiously)
Security Validation
Script: scripts/validate-public-sync.js
Scans For:
- Internal file paths (
/home/,/var/www/) - Database names (
tractatus_dev,tractatus_prod) - Port numbers (27017, 9000, etc.)
- IP addresses and server hostnames
- Email addresses (except public)
- SSH keys and credentials
- API keys and tokens
- Cross-project references
- Internal documentation markers
Exit Codes:
0= PASS (safe to sync)1= FAIL (security issues found, sync blocked)2= ERROR (validation system failure)
Severity Levels:
- CRITICAL: Immediate block (credentials, SSH keys)
- HIGH: Block sync (paths, database names, IPs)
- MEDIUM: Block sync (ports, emails, service names)
- LOW: Block sync (process management commands)
Sync Process
- Checkout both repos (private and public)
- Install dependencies in private repo
- Run security validation (unless manually skipped)
- Copy approved files from private to public staging
- Commit changes with automated message
- Push to public repo on main branch
- Create sync report (uploaded as artifact)
- Notify on failure (creates GitHub issue)
README Sync Special Case
The private README.md will only sync if it contains this marker:
<!-- PUBLIC_REPO_SAFE -->
Add this comment at the top of README.md when it's been sanitized for public consumption.
Without this marker: README is skipped (remains private-only) With this marker: README is synced to public repo
Troubleshooting
Sync Blocked - Security Issues Found
Symptom: Workflow fails with "Security validation failed - sync blocked"
Solution:
- Download the sync report artifact from the workflow run
- Review the detected security issues
- Fix the issues in the source files
- Push the fixes to main (triggers new sync)
Common issues:
- Database names in examples → Use
[DATABASE_NAME]placeholder - Internal paths in commands → Use generic paths or
[PATH] - Port numbers in configs → Use
[PORT]placeholder
Manual Approval Not Triggering
Symptom: Workflow doesn't wait for approval
Solution:
- Verify
public-syncenvironment exists - Check required reviewers are configured
- Ensure workflow references correct environment name
Token Expired
Symptom: Push to public repo fails with authentication error
Solution:
- Generate new PAT (same permissions)
- Update
PUBLIC_REPO_TOKENsecret in repository settings - Re-run failed workflow
Files Not Syncing
Check:
- Are files in the correct directories? (
docs/case-studies/,docs/research/) - Are files
.mdformat? - Does README have
<!-- PUBLIC_REPO_SAFE -->marker? - Check workflow logs for specific errors
Sync Report
After each run, a sync report is generated and uploaded as an artifact:
Contents:
- Validation status (pass/fail)
- Number of files synced
- List of changed files
- Any errors encountered
Access:
- Go to workflow run page
- Scroll to "Artifacts" section
- Download
sync-report
Retention: 30 days
Security Best Practices
Before Committing New Docs
Run local validation:
node scripts/validate-public-sync.js
This runs the same security checks that GitHub Actions will run.
Fix issues locally before pushing to avoid failed workflow runs.
Marking README as Safe
Only add <!-- PUBLIC_REPO_SAFE --> to README.md after:
- Running security validation
- Reviewing all content for internal references
- Confirming no infrastructure details exposed
- Verifying no cross-project references
Emergency: Disable Sync
If you need to temporarily disable automatic sync:
Option 1: Delete or rename the workflow file
git mv .github/workflows/sync-public-docs.yml .github/workflows/sync-public-docs.yml.disabled
git commit -m "chore: temporarily disable auto-sync"
git push
Option 2: Disable the workflow in GitHub
- Go to Actions tab
- Select "Sync Documentation to Public Repository"
- Click "..." → "Disable workflow"
Revoking Access
If token is compromised:
- Go to GitHub → Settings → Developer settings → Personal access tokens
- Find the token → Click "Delete"
- Generate new token
- Update
PUBLIC_REPO_TOKENsecret - Old token is immediately invalidated
Maintenance
Updating Validation Patterns
Edit scripts/validate-public-sync.js:
const SECURITY_PATTERNS = [
{
pattern: /your-new-pattern/gi,
severity: 'HIGH',
description: 'What this pattern detects',
category: 'Pattern Category'
},
// ... existing patterns
];
Test changes locally:
node scripts/validate-public-sync.js
Updating Workflow
Edit .github/workflows/sync-public-docs.yml
Common changes:
- Add new file paths to sync
- Modify trigger conditions
- Update Node.js version
- Adjust manual approval requirements
Files
GitHub Actions:
.github/workflows/sync-public-docs.yml- Main workflow
Scripts:
scripts/validate-public-sync.js- Security validation
Documentation:
docs/AUTOMATED_SYNC_SETUP.md- This file
Generated:
sync-report.md- Created during each run (artifact only)
Support
Workflow failures: Check Actions tab → View logs Security validation: Review sync report artifact Token issues: Regenerate PAT and update secret Questions: See GitHub Actions documentation
Last validated: 2025-10-09 Validation script version: 1.0 Workflow version: 1.0