mirror of
https://github.com/elyby/docs.git
synced 2026-11-29 19:03:23 +05:30
- Add crowdin.yml for the Docusaurus layout: documentation pages and UI strings (navbar, footer) with Russian as the source language. Docusaurus theme strings (code.json) are excluded, since the theme already has translations - Add the CI workflow: uploads sources to Crowdin and downloads translations on master, builds and deploys to GitHub Pages, nightly rebuild with fresh translations. Local translations (i18n/en) are uploaded to Crowdin only on demand: with "[crowdin upload translations]" in the commit message or via a manual run - Publish languages other than Russian and English only when their translation progress in Crowdin is at least 60% (scripts/crowdin-locales.mjs, DOCS_LOCALES) - Add Chinese (zh-Hans, served under /zh/) to the locales configuration - Generate the root index.html and robots.txt from the actually built locales - Keep only the English translation in the repository, other i18n dirs are generated
102 lines
2.9 KiB
YAML
102 lines
2.9 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
pull_request:
|
|
schedule:
|
|
# Nightly build to publish fresh translations from Crowdin
|
|
- cron: '0 2 * * *'
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22
|
|
cache: npm
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Generate source UI strings
|
|
run: npm run write-translations -- --locale ru --override
|
|
|
|
- name: Push and pull strings from the Crowdin
|
|
uses: crowdin/github-action@v2
|
|
if: github.ref == 'refs/heads/master'
|
|
with:
|
|
upload_sources: ${{ github.event_name == 'push' || github.event_name == 'workflow_dispatch' }}
|
|
upload_translations: false
|
|
download_translations: true
|
|
push_translations: false
|
|
env:
|
|
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
|
|
|
|
- name: Fix permissions to the i18n dir
|
|
if: github.ref == 'refs/heads/master'
|
|
run: sudo chown -R "$USER:$USER" i18n
|
|
|
|
- name: Detect locales to publish
|
|
if: github.ref == 'refs/heads/master'
|
|
run: echo "DOCS_LOCALES=$(node scripts/crowdin-locales.mjs)" >> "$GITHUB_ENV"
|
|
env:
|
|
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
|
|
|
|
- name: Typecheck
|
|
run: npm run typecheck
|
|
|
|
- name: Build docs
|
|
run: npm run build
|
|
|
|
- name: Upload build artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: build
|
|
path: build
|
|
include-hidden-files: true
|
|
retention-days: 7
|
|
|
|
- id: detect-diffs
|
|
name: Detect diffs
|
|
if: github.event_name == 'schedule'
|
|
run: |
|
|
git fetch origin
|
|
if [[ -z "$(git ls-remote --heads origin gh-pages)" ]]; then
|
|
echo "::warning::gh-pages branch doesn't exist"
|
|
echo "should-continue=false" >> "$GITHUB_OUTPUT"
|
|
exit
|
|
fi
|
|
|
|
tmp_dir=$(mktemp -du)
|
|
git worktree add "$tmp_dir" origin/gh-pages
|
|
|
|
if diff -qrbB --exclude=.git build "$tmp_dir" > /dev/null; then
|
|
echo "should-continue=false" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "should-continue=true" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
- name: Deploy to the GitHub Pages
|
|
uses: JamesIves/github-pages-deploy-action@v4
|
|
if: |
|
|
(github.event_name == 'push' && github.ref == 'refs/heads/master') ||
|
|
(github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/master') ||
|
|
(github.event_name == 'schedule' && steps.detect-diffs.outputs.should-continue == 'true')
|
|
with:
|
|
branch: gh-pages
|
|
folder: build
|
|
single-commit: true
|