Skip to content

Sync Documentation

Sync Documentation #2

Workflow file for this run

name: Sync Documentation
on:
workflow_dispatch:
inputs:
source_repo:
description: 'Source repository (owner/repo)'
required: true
default: 'diffyne/docs'
source_path:
description: 'Path to docs in source repo (leave empty for root)'
required: false
default: ''
schedule:
# Run daily at 2 AM UTC
- cron: '0 2 * * *'
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout this repo
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout source repo
uses: actions/checkout@v4
with:
repository: ${{ github.event.inputs.source_repo || 'diffyne/docs' }}
path: source-repo
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 24
cache: 'npm'
cache-dependency-path: package-lock.json
- name: Install dependencies
run: npm ci
- name: Copy versions config from docs repo
run: |
if [ -f source-repo/versions.json ]; then
cp source-repo/versions.json docs/.vitepress/versions.json
echo "✅ Copied versions.json from docs repo"
else
echo "⚠️ versions.json not found in docs repo, using default"
fi
- name: Sync all versions from docs repo (branch-based)
run: npm run sync:all
env:
DOCS_SOURCE_PATH: ./source-repo/${{ github.event.inputs.source_path || '' }}
- name: Check for changes
id: check
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "changed=true" >> $GITHUB_OUTPUT
else
echo "changed=false" >> $GITHUB_OUTPUT
fi
- name: Commit and push changes
if: steps.check.outputs.changed == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add docs/
git commit -m "docs: sync from main repository"
git push