|
| 1 | +name: Sync toolkit docs to website |
| 2 | + |
| 3 | +# Issue #38: toolkit-owned docs are authoritative for CLI / MCP / SDK / |
| 4 | +# coding-agent setup. When they change on main, open a PR back to |
| 5 | +# WonderfulValley/qveris-website:release/test so the website mirror stays |
| 6 | +# in sync. Website-owned docs (rest-api, cookbook, openapi) are excluded |
| 7 | +# from the trigger so this workflow cannot create a sync loop. |
| 8 | + |
| 9 | +on: |
| 10 | + push: |
| 11 | + branches: |
| 12 | + - main |
| 13 | + paths: |
| 14 | + # Toolkit-owned docs (matches qveris-website docs/.source-manifest.json |
| 15 | + # sources.toolkit_owned). cn/zh-CN docs are toolkit-only and not mirrored. |
| 16 | + - "docs/en-US/cli.md" |
| 17 | + - "docs/zh-CN/cli.md" |
| 18 | + - "docs/en-US/mcp-server.md" |
| 19 | + - "docs/zh-CN/mcp-server.md" |
| 20 | + - "docs/en-US/ide-cli-setup.md" |
| 21 | + - "docs/zh-CN/ide-cli-setup.md" |
| 22 | + - "docs/en-US/claude-code-setup.md" |
| 23 | + - "docs/zh-CN/claude-code-setup.md" |
| 24 | + - "docs/en-US/opencode-setup.md" |
| 25 | + - "docs/zh-CN/opencode-setup.md" |
| 26 | + # SDK docs (added after the manifest's last policy update; the website |
| 27 | + # manifest must list these before sync-docs.mjs will mirror them). |
| 28 | + - "docs/en-US/python-sdk.md" |
| 29 | + - "docs/zh-CN/python-sdk.md" |
| 30 | + - ".github/workflows/sync-docs-to-website.yml" |
| 31 | + workflow_dispatch: |
| 32 | + |
| 33 | +permissions: |
| 34 | + contents: read |
| 35 | + |
| 36 | +concurrency: |
| 37 | + group: sync-docs-to-website |
| 38 | + cancel-in-progress: false |
| 39 | + |
| 40 | +jobs: |
| 41 | + sync: |
| 42 | + runs-on: ubuntu-latest |
| 43 | + env: |
| 44 | + WEBSITE_SYNC_TOKEN: ${{ secrets.WEBSITE_SYNC_TOKEN }} |
| 45 | + WEBSITE_REPO: WonderfulValley/qveris-website |
| 46 | + WEBSITE_BASE: release/test |
| 47 | + |
| 48 | + steps: |
| 49 | + - name: Check sync token |
| 50 | + id: guard |
| 51 | + run: | |
| 52 | + if [ -z "${WEBSITE_SYNC_TOKEN}" ]; then |
| 53 | + echo "WEBSITE_SYNC_TOKEN is not configured; skipping toolkit -> website docs sync." |
| 54 | + echo "skip=true" >> "$GITHUB_OUTPUT" |
| 55 | + else |
| 56 | + echo "skip=false" >> "$GITHUB_OUTPUT" |
| 57 | + fi |
| 58 | +
|
| 59 | + - name: Checkout toolkit |
| 60 | + if: steps.guard.outputs.skip != 'true' |
| 61 | + uses: actions/checkout@v4 |
| 62 | + with: |
| 63 | + path: qveris-agent-toolkit |
| 64 | + |
| 65 | + - name: Checkout website (release/test) |
| 66 | + if: steps.guard.outputs.skip != 'true' |
| 67 | + uses: actions/checkout@v4 |
| 68 | + with: |
| 69 | + repository: ${{ env.WEBSITE_REPO }} |
| 70 | + ref: ${{ env.WEBSITE_BASE }} |
| 71 | + token: ${{ secrets.WEBSITE_SYNC_TOKEN }} |
| 72 | + path: qveris-website |
| 73 | + |
| 74 | + - name: Setup Node.js |
| 75 | + if: steps.guard.outputs.skip != 'true' |
| 76 | + uses: actions/setup-node@v4 |
| 77 | + with: |
| 78 | + node-version: 20 |
| 79 | + |
| 80 | + - name: Mirror toolkit-owned docs into website checkout |
| 81 | + if: steps.guard.outputs.skip != 'true' |
| 82 | + working-directory: qveris-website |
| 83 | + run: node scripts/sync-docs.mjs --from-toolkit --toolkit-dir ../qveris-agent-toolkit |
| 84 | + |
| 85 | + - name: Open website PR if docs changed |
| 86 | + if: steps.guard.outputs.skip != 'true' |
| 87 | + working-directory: qveris-website |
| 88 | + env: |
| 89 | + GH_TOKEN: ${{ secrets.WEBSITE_SYNC_TOKEN }} |
| 90 | + TOOLKIT_SHA: ${{ github.sha }} |
| 91 | + run: | |
| 92 | + set -euo pipefail |
| 93 | + if [ -z "$(git status --porcelain)" ]; then |
| 94 | + echo "No website doc changes after sync; nothing to open." |
| 95 | + exit 0 |
| 96 | + fi |
| 97 | +
|
| 98 | + SHORT_SHA="$(echo "${TOOLKIT_SHA}" | cut -c1-12)" |
| 99 | + BRANCH="sync/toolkit-docs-${SHORT_SHA}" |
| 100 | +
|
| 101 | + git config user.name "qveris-docs-sync[bot]" |
| 102 | + git config user.email "qveris-docs-sync@users.noreply.github.com" |
| 103 | + git checkout -b "${BRANCH}" |
| 104 | + git add -A |
| 105 | + git commit -m "docs: sync toolkit-owned docs from qveris-agent-toolkit@${SHORT_SHA}" |
| 106 | + git push --force origin "${BRANCH}" |
| 107 | +
|
| 108 | + BODY="$(cat <<EOF |
| 109 | + Automated mirror of **toolkit-owned** docs from \`QVerisAI/qveris-agent-toolkit\` @ \`${SHORT_SHA}\`. |
| 110 | +
|
| 111 | + Source of truth is the toolkit repo (CLI / MCP / SDK / coding-agent setup docs). Generated by \`.github/workflows/sync-docs-to-website.yml\` via \`scripts/sync-docs.mjs --from-toolkit\`. Website-owned docs (rest-api, cookbook, openapi) are not touched by this workflow. |
| 112 | + EOF |
| 113 | + )" |
| 114 | +
|
| 115 | + OPEN_COUNT="$(gh pr list --repo "${WEBSITE_REPO}" --head "${BRANCH}" --base "${WEBSITE_BASE}" --state open --json number --jq 'length')" |
| 116 | + if [ "${OPEN_COUNT}" != "0" ]; then |
| 117 | + echo "PR for ${BRANCH} already open; branch updated, no new PR created." |
| 118 | + else |
| 119 | + gh pr create \ |
| 120 | + --repo "${WEBSITE_REPO}" \ |
| 121 | + --base "${WEBSITE_BASE}" \ |
| 122 | + --head "${BRANCH}" \ |
| 123 | + --title "docs: sync toolkit-owned docs (qveris-agent-toolkit@${SHORT_SHA})" \ |
| 124 | + --body "${BODY}" |
| 125 | + fi |
0 commit comments