2023-01-06 16:03:13 +08:00
|
|
|
# Simple workflow for deploying static content to GitHub Pages
|
|
|
|
name: Deploy static content to Pages
|
|
|
|
|
|
|
|
on:
|
|
|
|
# Runs on pushes targeting the default branch
|
|
|
|
push:
|
2023-06-09 15:07:49 +08:00
|
|
|
paths:
|
|
|
|
- "docs/**"
|
2023-06-11 17:44:53 +08:00
|
|
|
- ".github/workflows/page.yml"
|
|
|
|
- "**README**"
|
2023-01-06 16:03:13 +08:00
|
|
|
branches: ["main"]
|
|
|
|
|
|
|
|
# Allows you to run this workflow manually from the Actions tab
|
|
|
|
workflow_dispatch:
|
|
|
|
|
|
|
|
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
pages: write
|
|
|
|
id-token: write
|
|
|
|
|
|
|
|
# Allow one concurrent deployment
|
|
|
|
concurrency:
|
|
|
|
group: "pages"
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
# Single deploy job since we're just deploying
|
|
|
|
deploy:
|
2023-01-23 01:16:11 +08:00
|
|
|
if: ${{!startsWith(github.event.ref, 'refs/tags/') && contains(github.event.head_commit.message, '[page skip]') == false }}
|
2023-01-06 16:03:13 +08:00
|
|
|
environment:
|
|
|
|
name: github-pages
|
|
|
|
url: ${{ steps.deployment.outputs.page_url }}
|
2023-03-11 15:04:15 +08:00
|
|
|
|
2023-01-06 16:03:13 +08:00
|
|
|
runs-on: ubuntu-latest
|
2023-03-11 15:04:15 +08:00
|
|
|
|
2023-01-06 16:03:13 +08:00
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
|
|
|
|
- name: Setup Pages
|
|
|
|
uses: actions/configure-pages@v2
|
|
|
|
|
2023-03-11 15:20:06 +08:00
|
|
|
- name: 安装 mdbook
|
2023-01-17 23:54:40 +08:00
|
|
|
uses: extractions/setup-mdbook@v1
|
2023-01-06 16:03:13 +08:00
|
|
|
|
2023-03-11 15:20:06 +08:00
|
|
|
- name: Install mdBook
|
|
|
|
shell: pwsh
|
|
|
|
run: |
|
|
|
|
# 设置变量
|
|
|
|
$urls = @(
|
2023-07-14 00:22:50 +08:00
|
|
|
'https://github.com/shenjackyuanjie/Minecraft_Science_Tree/releases/download/0.0.4/mdbook-i18n',
|
|
|
|
'https://github.com/shenjackyuanjie/Minecraft_Science_Tree/releases/download/0.0.4/mdbook-theme',
|
|
|
|
'https://github.com/shenjackyuanjie/Minecraft_Science_Tree/releases/download/0.0.4/mdbook-cmdrun',
|
|
|
|
'https://github.com/shenjackyuanjie/Minecraft_Science_Tree/releases/download/0.0.4/mdbook-pagetoc',
|
|
|
|
'https://github.com/shenjackyuanjie/Minecraft_Science_Tree/releases/download/0.0.4/mdbook-footnote',
|
|
|
|
'https://github.com/shenjackyuanjie/Minecraft_Science_Tree/releases/download/0.0.4/mdbook-external-links',
|
2023-03-11 15:20:06 +08:00
|
|
|
'https://github.com/plantuml/plantuml/releases/download/v1.2023.4/plantuml-1.2023.4.jar'
|
|
|
|
)
|
|
|
|
# 下载文件
|
|
|
|
foreach ($url in $urls) {
|
2023-03-18 14:55:36 +08:00
|
|
|
Invoke-WebRequest -Uri $url -OutFile "$($url.Split('/')[-1])"
|
2023-03-11 15:20:06 +08:00
|
|
|
}
|
|
|
|
# 将目录路径添加到 $PATH 中
|
2023-03-18 14:55:36 +08:00
|
|
|
$PWD >> $env:GITHUB_PATH
|
|
|
|
ls $PWD
|
|
|
|
|
|
|
|
# - name: Setup mdbook-theme latest
|
|
|
|
# run: |
|
|
|
|
# curl -s https://api.github.com/repos/zjp-CN/mdbook-theme/releases/latest \
|
|
|
|
# | grep browser_download_url \
|
|
|
|
# | grep mdbook-theme_linux \
|
|
|
|
# | cut -d '"' -f 4 \
|
|
|
|
# | wget -qi -
|
|
|
|
# tar -xvzf mdbook-theme_linux.tar.gz
|
|
|
|
# echo $PWD >> $GITHUB_PATH
|
2023-03-11 15:20:06 +08:00
|
|
|
|
|
|
|
- name: 安装 python 3.11
|
2023-03-11 15:04:15 +08:00
|
|
|
uses: actions/setup-python@v2
|
|
|
|
with:
|
|
|
|
python-version: 3.11
|
|
|
|
|
2023-03-11 15:20:06 +08:00
|
|
|
- name: 安装 dsm api
|
2023-03-11 15:04:15 +08:00
|
|
|
shell: pwsh
|
|
|
|
run: |
|
|
|
|
pip install synology-api>=0.5.1
|
|
|
|
|
|
|
|
- name: build mdbook
|
2023-01-06 16:03:13 +08:00
|
|
|
shell: pwsh
|
2023-01-06 16:14:31 +08:00
|
|
|
run: |
|
2023-03-18 14:55:36 +08:00
|
|
|
# cp docs/theme .
|
|
|
|
cd docs
|
|
|
|
mdbook build
|
|
|
|
cd ..
|
2023-05-16 21:55:39 +08:00
|
|
|
# Copy-Item docs/book/README-en.html docs/book/html/README-en.html
|
|
|
|
Copy-Item index.html docs/book/index.html
|
2023-05-16 21:59:29 +08:00
|
|
|
Get-ChildItem -Recurse -Path .\docs\book* | ?{$_.PsIsContainer -eq $false} | Get-FileHash -Algorithm MD5 >> .\docs\md5.txt
|
2023-01-06 16:03:13 +08:00
|
|
|
|
2023-03-11 15:04:15 +08:00
|
|
|
- name: 上传到 github pages
|
2023-01-06 16:03:13 +08:00
|
|
|
uses: actions/upload-pages-artifact@v1
|
|
|
|
with:
|
|
|
|
# Upload entire repository
|
2023-05-16 21:59:29 +08:00
|
|
|
path: './docs/book'
|
2023-03-11 15:04:15 +08:00
|
|
|
|
|
|
|
- name: 部署到 github pages
|
2023-01-06 16:03:13 +08:00
|
|
|
id: deployment
|
2023-01-06 16:28:03 +08:00
|
|
|
uses: actions/deploy-pages@v1
|
2023-03-11 15:04:15 +08:00
|
|
|
|
|
|
|
- name: 上传到 DSM
|
|
|
|
env:
|
|
|
|
DSM_TOKEN: ${{ secrets.DSM_TOKEN }}
|
|
|
|
shell: pwsh
|
|
|
|
run: |
|
2023-03-11 15:20:06 +08:00
|
|
|
python .github/workflows/dsm.py -X utf8
|