185 lines
5.4 KiB
YAML
185 lines
5.4 KiB
YAML
name: Deploy to GitHub Pages
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
paths-ignore:
|
|
- '.github/CODEOWNERS'
|
|
- '.github/workflows/pr.yml'
|
|
- '.idea/**'
|
|
- '.vscode/**'
|
|
- '.gitattributes'
|
|
- '.gitignore'
|
|
- 'CONTRIBUTING.md'
|
|
- 'LICENSE'
|
|
- 'README.md'
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
pages: write
|
|
id-token: write
|
|
|
|
concurrency:
|
|
group: "pages"
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
sync:
|
|
name: Deploy to GitHub Pages
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
locales: ${{ steps.locales.outputs.locales }}
|
|
commit: ${{ steps.commit.outputs.commit-hash == '' && steps.commit.outputs.commit-hash || github.sha }}
|
|
permissions:
|
|
contents: write
|
|
env:
|
|
# Forks have no Crowdin secrets: skip the translation sync there, and deploy the pushed commit as is
|
|
CROWDIN_ENABLED: ${{ secrets.CROWDIN_TOKEN != '' }}
|
|
steps:
|
|
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1
|
|
with:
|
|
node-version: 22
|
|
package-manager-cache: false
|
|
|
|
- name: Enable Corepack
|
|
run: corepack enable
|
|
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1
|
|
with:
|
|
node-version: 22
|
|
cache: yarn
|
|
package-manager-cache: true
|
|
|
|
- name: Install dependencies
|
|
run: yarn install --immutable
|
|
|
|
- name: Sync Translations
|
|
if: env.CROWDIN_ENABLED == 'true'
|
|
run: yarn crowdin-sync
|
|
env:
|
|
CROWDIN_TOKEN: ${{ secrets.CROWDIN_TOKEN }}
|
|
CROWDIN_ORGANIZATION: ${{ secrets.CROWDIN_ORGANIZATION }}
|
|
|
|
- name: Commit Changes
|
|
if: env.CROWDIN_ENABLED == 'true'
|
|
id: commit
|
|
# See https://github.com/planetscale/ghcommit-action/releases
|
|
uses: planetscale/ghcommit-action@f24050e41f8694750427d111b52f4ef9ca81a32d # v0.2.18
|
|
with:
|
|
commit_message: "Sync translations with Crowdin"
|
|
repo: ${{ github.repository }}
|
|
branch: ${{ github.head_ref || github.ref_name }}
|
|
env:
|
|
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
|
|
|
- name: Get locales
|
|
run: yarn output-locales
|
|
|
|
- name: Define matrix
|
|
id: locales
|
|
run: echo "locales=$(cat locales.json)" >> $GITHUB_OUTPUT
|
|
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
needs: sync
|
|
strategy:
|
|
matrix:
|
|
locales: ${{ fromJson(needs.sync.outputs.locales) }}
|
|
steps:
|
|
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1
|
|
with:
|
|
node-version: 22
|
|
package-manager-cache: false
|
|
|
|
- name: Enable Corepack
|
|
run: corepack enable
|
|
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
|
|
with:
|
|
fetch-depth: 0
|
|
ref: ${{ needs.sync.outputs.commit }}
|
|
|
|
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1
|
|
with:
|
|
node-version: 22
|
|
package-manager-cache: false
|
|
|
|
- name: Restore Yarn Cache
|
|
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830
|
|
with:
|
|
path: /home/runner/.yarn/berry/cache
|
|
key: |
|
|
node-cache-${{ runner.os }}-x64-yarn-${{ hashFiles('**/yarn.lock') }}
|
|
restore-keys: |
|
|
node-cache-${{ runner.os }}-x64-yarn-
|
|
|
|
- name: Install dependencies
|
|
run: yarn install --immutable
|
|
|
|
- name: Restore Docusaurus Cache
|
|
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
|
|
with:
|
|
path: |
|
|
${{ github.workspace }}/.docusaurus
|
|
${{ github.workspace }}/**/.cache
|
|
key: |
|
|
${{ runner.os }}-docusaurus-${{ matrix.locales }}-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-docusaurus-${{ matrix.locales }}-${{ hashFiles('**/yarn.lock') }}
|
|
|
|
- name: Build Locale
|
|
run: yarn build --locale ${{ matrix.locales }}
|
|
env:
|
|
# The Mermaid theme makes the client bundle too large for Node's default heap
|
|
NODE_OPTIONS: --max-old-space-size=8192
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4
|
|
with:
|
|
path: build
|
|
name: ${{ matrix.locales }}
|
|
|
|
combine:
|
|
runs-on: ubuntu-latest
|
|
needs: [build, sync]
|
|
steps:
|
|
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
|
|
with:
|
|
fetch-depth: 0
|
|
ref: ${{ needs.sync.outputs.commit }}
|
|
|
|
- name: Setup Pages
|
|
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b
|
|
|
|
- name: Download artifacts
|
|
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53
|
|
with:
|
|
path: build
|
|
|
|
- name: Move default locale to root build
|
|
run: |
|
|
mv build/en/* build/
|
|
rm -rf build/en
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b
|
|
with:
|
|
path: build
|
|
|
|
deploy:
|
|
environment:
|
|
name: github-pages
|
|
url: ${{ steps.deployment.outputs.page_url }}
|
|
runs-on: ubuntu-latest
|
|
needs: combine
|
|
steps:
|
|
- name: Deploy to GitHub Pages
|
|
id: deployment
|
|
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e
|