Deploy #52
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy | |
on: | |
workflow_dispatch: | |
merge_group: | |
push: | |
branches: | |
- main | |
paths: | |
- 'docs/**' | |
- 'theme/**' | |
- 'po/**' | |
- book.toml | |
- .github/workflows/docs.yaml | |
pull_request: | |
paths: | |
- 'docs/**' | |
- 'theme/**' | |
- 'po/**' | |
- book.toml | |
- .github/workflows/docs.yaml | |
permissions: | |
pages: write | |
id-token: write | |
jobs: | |
build-doc: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup mdBook | |
uses: peaceiris/actions-mdbook@v2 | |
with: | |
mdbook-version: 'latest' | |
- name: Install mdbook plugins | |
shell: bash | |
run: | | |
cargo install mdbook-admonish | |
cargo install mdbook-i18n-helpers | |
- name: Build | |
run: | | |
mdbook build | |
for po_lang in zh-CN | |
do | |
POT_CREATION_DATE=$(grep --max-count 1 '^"POT-Creation-Date:' po/$po_lang.po | sed -E 's/".*: (.*)\\n"/\1/') | |
if [[ $POT_CREATION_DATE == "" ]]; then | |
POT_CREATION_DATE=now | |
fi | |
echo "::group::Building $po_lang translation as of $POT_CREATION_DATE" | |
rm -r docs/ | |
git restore --source "$(git rev-list -n 1 --before "$POT_CREATION_DATE" @)" docs/ | |
# Set language and adjust site URL. Clear the redirects | |
# since they are in sync with the source files, not the | |
# translation. | |
MDBOOK_BOOK__LANGUAGE=$po_lang \ | |
MDBOOK_OUTPUT__HTML__SITE_URL=/bsp/$po_lang/ \ | |
MDBOOK_OUTPUT__HTML__REDIRECT='{}' \ | |
mdbook build -d book/$po_lang | |
echo "::endgroup::" | |
done | |
- name: Setup Pages | |
uses: actions/configure-pages@v5 | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
# Upload entire repository | |
path: "./book" | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 | |
if: github.event_name != 'pull_request' && github.event_name != 'merge_group' |