mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-10-30 12:25:29 +08:00
The migrated workflows required LANGBOT_WIKI_PUSH_TOKEN, which only exists in the langbot-docs repository. The existing RELEASE_UPLOAD_GITHUB_TOKEN was verified to authenticate as the owner with repo scope plus push/admin on LangBot, langbot-docs, langbot-landing-page and the production fork, and it can push the Wiki, so publication now falls back to it when the dedicated secret is absent. Also retarget the cutover notes at the master branch. Co-Authored-By: Mika (Multica) <[email protected]> Co-authored-by: multica-agent <[email protected]>
91 lines
2.8 KiB
YAML
91 lines
2.8 KiB
YAML
name: Sync GitHub Wiki
|
|
|
|
on:
|
|
push:
|
|
branches: [master]
|
|
paths:
|
|
- "docs/en/**"
|
|
- "docs/zh/**"
|
|
- "docs/ja/**"
|
|
- "docs/scripts/build-github-wiki.py"
|
|
- ".github/workflows/sync-github-wiki.yml"
|
|
pull_request:
|
|
paths:
|
|
- "docs/en/**"
|
|
- "docs/zh/**"
|
|
- "docs/ja/**"
|
|
- "docs/scripts/build-github-wiki.py"
|
|
- "docs/tests/test_build_github_wiki.py"
|
|
- ".github/workflows/sync-github-wiki.yml"
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: sync-langbot-github-wiki
|
|
cancel-in-progress: false
|
|
|
|
jobs:
|
|
build:
|
|
defaults:
|
|
run:
|
|
working-directory: docs
|
|
name: Build Wiki mirror
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 5
|
|
steps:
|
|
- uses: actions/checkout@v7
|
|
- uses: actions/setup-python@v7
|
|
with:
|
|
python-version: "3.12"
|
|
- name: Run converter tests
|
|
run: python -m unittest tests/test_build_github_wiki.py
|
|
- name: Build Wiki pages
|
|
run: python scripts/build-github-wiki.py --output dist/github-wiki
|
|
- name: Validate generated pages
|
|
run: |
|
|
test -f dist/github-wiki/Home.md
|
|
test -f dist/github-wiki/_Sidebar.md
|
|
test "$(find dist/github-wiki -maxdepth 1 -name '*.md' | wc -l)" -gt 250
|
|
- name: Upload generated Wiki
|
|
uses: actions/upload-artifact@v7
|
|
with:
|
|
name: github-wiki
|
|
path: docs/dist/github-wiki
|
|
if-no-files-found: error
|
|
|
|
sync:
|
|
name: Publish to LangBot Wiki
|
|
if: github.event_name != 'pull_request' && github.repository == 'langbot-app/LangBot' && github.ref == 'refs/heads/master' && vars.DOCS_MIRROR_ENABLED == 'true'
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 5
|
|
steps:
|
|
- uses: actions/download-artifact@v8
|
|
with:
|
|
name: github-wiki
|
|
path: generated
|
|
- name: Clone target Wiki
|
|
env:
|
|
WIKI_PUSH_TOKEN: ${{ secrets.LANGBOT_WIKI_PUSH_TOKEN || secrets.RELEASE_UPLOAD_GITHUB_TOKEN }}
|
|
run: |
|
|
test -n "$WIKI_PUSH_TOKEN"
|
|
git clone "https://x-access-token:${WIKI_PUSH_TOKEN}@github.com/langbot-app/LangBot.wiki.git" target
|
|
- name: Replace and publish Wiki contents
|
|
env:
|
|
SOURCE_SHA: ${{ github.sha }}
|
|
run: |
|
|
find target -mindepth 1 -maxdepth 1 ! -name .git -exec rm -rf {} +
|
|
cp -a generated/. target/
|
|
cd target
|
|
git add -A
|
|
if git diff --cached --quiet; then
|
|
echo "GitHub Wiki is already up to date."
|
|
exit 0
|
|
fi
|
|
git config user.name "langbot-docs-sync[bot]"
|
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
git commit -m "docs: sync from LangBot/docs@${SOURCE_SHA::7}"
|
|
git push origin HEAD:master
|