From 57d113fc94e6300c1b2d355545ad5f5abe254ff5 Mon Sep 17 00:00:00 2001 From: shenjack <3695888@qq.com> Date: Sat, 11 Mar 2023 15:04:15 +0800 Subject: [PATCH] try to use dsm Update page.yml Update page.yml --- .github/workflows/dsm.py | 31 +++++++++++++++++++++++++++++++ .github/workflows/page.yml | 29 ++++++++++++++++++++++++++--- .github/workflows/requirement.txt | 5 ++++- 3 files changed, 61 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/dsm.py diff --git a/.github/workflows/dsm.py b/.github/workflows/dsm.py new file mode 100644 index 0000000..85c16ee --- /dev/null +++ b/.github/workflows/dsm.py @@ -0,0 +1,31 @@ +# ------------------------------- +# Difficult Rocket +# Copyright © 2020-2023 by shenjackyuanjie 3695888@qq.com +# All rights reserved +# ------------------------------- + +import os +from synology_api import filestation + +# 输出 文档构建目录 的内容 +docs_build = 'docs/book/html' + +for root, dirs, files in os.walk(docs_build): + print(root, dirs, files) + +# 获取 token +token = os.environ['DSM_TOKEN'] +username = os.environ['DSM_USERNAME'] + +fl = filestation.FileStation(ip_address='hws.shenjack.top', + port=5000, + username=username, + password=token, + secure=False, + cert_verify=False, + dsm_version=7, + debug=True) + +print(fl.get_info()) + +print(fl.get_file_list('/web')) diff --git a/.github/workflows/page.yml b/.github/workflows/page.yml index 078706b..9505784 100644 --- a/.github/workflows/page.yml +++ b/.github/workflows/page.yml @@ -27,7 +27,9 @@ jobs: environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: - name: Checkout uses: actions/checkout@v3 @@ -38,16 +40,37 @@ jobs: - name: install mdbook uses: extractions/setup-mdbook@v1 - - name: setup、build mdbook + - name: setup python 3.11 + uses: actions/setup-python@v2 + with: + python-version: 3.11 + + - name: install dsm api + shell: pwsh + run: | + pip install synology-api>=0.5.1 + + - name: build mdbook shell: pwsh run: | mdbook build ./docs/ + cd docs + Copy-Item book/README-en.html book/html/README-en.html - - name: Upload artifact + - name: 上传到 github pages uses: actions/upload-pages-artifact@v1 with: # Upload entire repository path: './docs/book/html' - - name: Deploy to GitHub Pages + + - name: 部署到 github pages id: deployment uses: actions/deploy-pages@v1 + + - name: 上传到 DSM + env: + DSM_TOKEN: ${{ secrets.DSM_TOKEN }} + DSM_USERNAME: ${{ secrets.DSM_USERNAME }} + shell: pwsh + run: | + python .github/workflows/dsm.py diff --git a/.github/workflows/requirement.txt b/.github/workflows/requirement.txt index ddeba2a..e137505 100644 --- a/.github/workflows/requirement.txt +++ b/.github/workflows/requirement.txt @@ -1,2 +1,5 @@ # for checker -ruff >= 0.0.253 \ No newline at end of file +# ruff >= 0.0.253 + +# for dsm upload +synology-api >= 0.5.1 \ No newline at end of file