Difficult-Rocket/.github/workflows/page.yml

111 lines
3.6 KiB
YAML
Raw Normal View History

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:
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-01-06 16:03:13 +08:00
runs-on: ubuntu-latest
2023-01-06 16:03:13 +08:00
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Pages
uses: actions/configure-pages@v2
- name: 安装 mdbook
2023-01-17 23:54:40 +08:00
uses: extractions/setup-mdbook@v1
2023-01-06 16:03:13 +08:00
- name: Install mdBook
shell: pwsh
run: |
# 设置变量
$urls = @(
2023-03-19 10:58:38 +08:00
'https://github.com/shenjackyuanjie/Minecraft_Science_Tree/releases/download/0.0.3/mdbook-i18n',
'https://github.com/shenjackyuanjie/Minecraft_Science_Tree/releases/download/0.0.3/mdbook-theme',
'https://github.com/shenjackyuanjie/Minecraft_Science_Tree/releases/download/0.0.3/mdbook-cmdrun',
'https://github.com/shenjackyuanjie/Minecraft_Science_Tree/releases/download/0.0.3/mdbook-pagetoc',
2023-03-19 10:58:38 +08:00
'https://github.com/shenjackyuanjie/Minecraft_Science_Tree/releases/download/0.0.3/mdbook-footnote',
'https://github.com/shenjackyuanjie/Minecraft_Science_Tree/releases/download/0.0.3/mdbook-external-links',
'https://github.com/plantuml/plantuml/releases/download/v1.2023.4/plantuml-1.2023.4.jar'
)
# 下载文件
foreach ($url in $urls) {
Invoke-WebRequest -Uri $url -OutFile "$($url.Split('/')[-1])"
}
# 将目录路径添加到 $PATH 中
$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
- name: 安装 python 3.11
uses: actions/setup-python@v2
with:
python-version: 3.11
- name: 安装 dsm api
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: |
# 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
Get-ChildItem -Recurse -Path .\docs\book* | ?{$_.PsIsContainer -eq $false} | Get-FileHash -Algorithm MD5 >> .\docs\md5.txt
2023-01-06 16:03:13 +08:00
- name: 上传到 github pages
2023-01-06 16:03:13 +08:00
uses: actions/upload-pages-artifact@v1
with:
# Upload entire repository
path: './docs/book'
- 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
- name: 上传到 DSM
env:
DSM_TOKEN: ${{ secrets.DSM_TOKEN }}
shell: pwsh
run: |
python .github/workflows/dsm.py -X utf8