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

115 lines
4.2 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: 安装 mdbook 扩展
# shell: pwsh
# run: |
# # mdbook mdbook-i18n mdbook-footnote mdbook-pagetoc mdbook-cmdrun
# Write-Host "GITHUB_PATH is: $env:GITHUB_PATH"
# $mdbookPath = "$env:GITHUB_PATH\mdbook.exe"
# Write-Host "mdbook path is: $mdbookPath"
# Invoke-WebRequest -Uri "http://shenjack.top:81/mdbook/mdbook-i18n.exe" -OutFile $env:GITHUB_PATH\mdbook-i18n.exe
# Invoke-WebRequest -Uri "http://shenjack.top:81/mdbook/mdbook-cmdrun.exe" -OutFile $env:GITHUB_PATH\mdbook-cmdrun.exe
# Invoke-WebRequest -Uri "http://shenjack.top:81/mdbook/mdbook-pagetoc.exe" -OutFile $env:GITHUB_PATH\mdbook-pagetoc.exe
# Invoke-WebRequest -Uri "http://shenjack.top:81/mdbook/mdbook-footnote.exe" -OutFile $env:GITHUB_PATH\mdbook-footnote.exe
- name: Install mdBook
shell: pwsh
run: |
# 设置变量
$urls = @(
'https://github.com/shenjackyuanjie/Minecraft_Science_Tree/releases/download/0.0.2/mdbook-i18n',
'https://github.com/shenjackyuanjie/Minecraft_Science_Tree/releases/download/0.0.2/mdbook-cmdrun',
'https://github.com/shenjackyuanjie/Minecraft_Science_Tree/releases/download/0.0.3/mdbook-pagetoc',
'https://github.com/shenjackyuanjie/Minecraft_Science_Tree/releases/download/0.0.2/mdbook-footnote',
'https://github.com/plantuml/plantuml/releases/download/v1.2023.4/plantuml-1.2023.4.jar'
)
$temp = 'mdbook'
# 创建目录
if (!(Test-Path -Path $temp -PathType Container)) {
New-Item -Path $temp -ItemType Directory -Force
}
# 下载文件
foreach ($url in $urls) {
Invoke-WebRequest -Uri $url -OutFile "$temp/$($url.Split('/')[-1])"
}
# Invoke-WebRequest -Uri $url1 -OutFile 'mdbook/mdbook-i18n'
# Invoke-WebRequest -Uri $url2 -OutFile 'mdbook/mdbook-cmdrun'
# Invoke-WebRequest -Uri $url3 -OutFile 'mdbook/mdbook-pagetoc'
# Invoke-WebRequest -Uri $url4 -OutFile 'mdbook/mdbook-footnote'
# 将目录路径添加到 $PATH 中
echo "$temp" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- 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: |
2023-02-21 23:05:52 +08:00
mdbook build ./docs/
Copy-Item docs/book/README-en.html docs/book/html/README-en.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
2023-02-21 23:05:52 +08:00
path: './docs/book/html'
- 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