-
Notifications
You must be signed in to change notification settings - Fork 1.7k
74 lines (65 loc) · 2.52 KB
/
sync-docs.yml
File metadata and controls
74 lines (65 loc) · 2.52 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 Docs to Website
on:
push:
branches: [main]
paths:
- 'docs/core/introduction.mdx'
- 'docs/core/get_started/**'
- 'docs/core/concepts/**'
- 'docs/core/guides/**'
- 'docs/core/reference/**'
permissions:
contents: read
jobs:
sync-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout WrenAI
uses: actions/checkout@v4
- name: Checkout doc website
uses: actions/checkout@v4
with:
repository: ${{ vars.DOCS_REPO }}
token: ${{ secrets.CROSS_REPO_TOKEN }}
path: _docs-site
ref: ${{ vars.DOCS_REPO_BRANCH }}
- name: Sync doc directories
run: |
TARGET="_docs-site/docs/oss"
mkdir -p "${TARGET}"
# Sync top-level files
cp "docs/core/introduction.mdx" "${TARGET}/introduction.mdx"
# Sync directories — additive overlay
# No rm -rf: this action ONLY copies/overwrites. Stale files left
# behind by source-side renames/deletions must be cleaned up
# MANUALLY by a maintainer in the docs site repo.
# The plural folder names (concepts, guides) are deliberately
# different from GenBI legacy's singular names (concept, guide,
# under docs/oss/genbi/ on the docs site) to keep them in
# separate trees under docs/oss/.
for dir in get_started concepts guides reference; do
mkdir -p "${TARGET}/${dir}"
cp -r "docs/core/${dir}/." "${TARGET}/${dir}/"
done
- name: Check for changes
id: diff
working-directory: _docs-site
run: |
git diff --quiet && echo "changed=false" >> "$GITHUB_OUTPUT" || echo "changed=true" >> "$GITHUB_OUTPUT"
- name: Create PR
if: steps.diff.outputs.changed == 'true'
working-directory: _docs-site
env:
GH_TOKEN: ${{ secrets.CROSS_REPO_TOKEN }}
run: |
BRANCH="sync/core-docs-${GITHUB_SHA::8}"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git checkout -b "${BRANCH}"
git add -A
git commit -m "docs: sync from WrenAI@${GITHUB_SHA::8}"
git push origin "${BRANCH}"
gh pr create \
--title "docs: sync Wren AI Core docs from WrenAI" \
--body "Auto-synced from [WrenAI@\`${GITHUB_SHA::8}\`](https://github.com/Canner/WrenAI/commit/${GITHUB_SHA})." \
--base "${{ vars.DOCS_REPO_BRANCH }}"