-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (65 loc) · 2.13 KB
/
sync-docs.yml
File metadata and controls
75 lines (65 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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