mirror of
https://github.com/elyby/docs.git
synced 2026-11-29 19:03:23 +05:30
Simplify deploy
This commit is contained in:
5 files changed
+31
-60
No files matched your search
+28
-45
@@ -3,13 +3,10 @@ name: CI
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
schedule:
|
||||
# Nightly build to publish fresh translations from Crowdin
|
||||
- cron: '0 2 * * *'
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
@@ -20,10 +17,10 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v7
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v4
|
||||
uses: actions/setup-node@v7
|
||||
with:
|
||||
node-version: 22
|
||||
cache: npm
|
||||
@@ -35,20 +32,16 @@ jobs:
|
||||
run: npm run write-translations -- --locale ru --override
|
||||
|
||||
- name: Push and pull strings from the Crowdin
|
||||
uses: crowdin/github-action@v2
|
||||
uses: crowdin/github-action@v3
|
||||
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
|
||||
# Run as the owner of the workspace instead of root, so the downloaded files belong to the runner user
|
||||
user: auto
|
||||
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"
|
||||
@@ -61,41 +54,31 @@ jobs:
|
||||
- name: Build docs
|
||||
run: npm run build
|
||||
|
||||
- name: Upload build artifacts
|
||||
uses: actions/upload-artifact@v4
|
||||
- name: Upload GitHub Pages artifact
|
||||
uses: actions/upload-pages-artifact@v5
|
||||
if: github.ref == 'refs/heads/master'
|
||||
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
|
||||
deploy:
|
||||
needs: build
|
||||
if: github.ref == 'refs/heads/master'
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
tmp_dir=$(mktemp -du)
|
||||
git worktree add "$tmp_dir" origin/gh-pages
|
||||
permissions:
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
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
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
|
||||
- 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
|
||||
# Never cancel a deployment in progress
|
||||
concurrency:
|
||||
group: pages
|
||||
cancel-in-progress: false
|
||||
|
||||
steps:
|
||||
- id: deployment
|
||||
name: Deploy to the GitHub Pages
|
||||
uses: actions/deploy-pages@v5
|
||||
@@ -11,8 +11,7 @@ npm ci
|
||||
npm run start
|
||||
```
|
||||
|
||||
The dev server shows the Russian version. To check another language, download the translations from Crowdin
|
||||
(requires the `CROWDIN_PERSONAL_TOKEN` environment variable) and start the server for that locale:
|
||||
The dev server shows the Russian version. To check another language, download the translations from Crowdin (requires the `CROWDIN_PERSONAL_TOKEN` environment variable) and start the server for that locale:
|
||||
|
||||
```sh
|
||||
npm run write-translations -- --locale ru --override
|
||||
@@ -24,12 +23,5 @@ npm run start -- --locale en
|
||||
|
||||
## Writing
|
||||
|
||||
- Pages are written in Russian in `docs/` (MDX). Don't wrap lines: one paragraph is one line.
|
||||
- Pages are written in Russian in `docs/` (MDX). Don't wrap lines: one paragraph is one line. Use soft-wrap with your preferred line width.
|
||||
- Translations are made only on [Crowdin](https://ely.crowdin.com). The `i18n/` directory is generated and not committed.
|
||||
- Keep the `{#id}` of headings: they are the anchors of the existing links.
|
||||
|
||||
## Deployment
|
||||
|
||||
Every push to `master` uploads the source strings to Crowdin, downloads the translations and deploys the site
|
||||
to the `gh-pages` branch. A language is published once its translation reaches 60%. The site is also rebuilt
|
||||
nightly to publish fresh translations.
|
||||
Whitespace-only changes.
@@ -1 +0,0 @@
|
||||
docs.ely.by
|
||||
@@ -1,7 +1,7 @@
|
||||
// Assembles the site root after "docusaurus build".
|
||||
// Every locale is built into its own build/<prefix>/ directory (see i18n.localeConfigs in
|
||||
// docusaurus.config.ts), so files that must live in the site root are placed here.
|
||||
import { cpSync, copyFileSync, existsSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
||||
import { copyFileSync, existsSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
||||
import { dirname, join } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
@@ -36,9 +36,6 @@ function languageName(lang) {
|
||||
return name.charAt(0).toLocaleUpperCase(lang) + name.slice(1);
|
||||
}
|
||||
|
||||
// CNAME and .nojekyll
|
||||
cpSync(join(projectDir, 'root'), buildDir, {recursive: true});
|
||||
|
||||
// GitHub Pages only serves the 404.html from the site root
|
||||
copyFileSync(join(buildDir, DEFAULT_PREFIX, '404.html'), join(buildDir, '404.html'));
|
||||
|
||||
|
||||
Reference in new issue
Block a user