文档-编译并部署 #21
This file contains hidden or 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: 文档-编译并部署 | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| compile-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: 检出 | |
| uses: actions/checkout@v4 | |
| - name: 安装Python | |
| uses: actions/setup-python@v3 | |
| with: | |
| python-version: '3.x' | |
| - name: 安装编译工具 | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install pymdown-extensions | |
| pip install mkdocs-material | |
| pip install -r requirements/requirements.txt | |
| - name: 编译 | |
| run: | | |
| mkdocs build | |
| zip -r -q -9 site.zip site | |
| ls -la | |
| - name: 上传 | |
| uses: appleboy/[email protected] | |
| with: | |
| host: ${{ secrets.CORDYS_DOCS_HOST }} | |
| username: ${{ secrets.CORDYS_DOCS_HOST_USERNAME }} | |
| port: 22 | |
| key: ${{ secrets.CORDYS_DOCS_HOST_KEY }} | |
| source: "site.zip" | |
| target: /tmp | |
| - name: 部署 | |
| uses: appleboy/[email protected] | |
| with: | |
| host: ${{ secrets.CORDYS_DOCS_HOST }} | |
| username: ${{ secrets.CORDYS_DOCS_HOST_USERNAME }} | |
| key: ${{ secrets.CORDYS_DOCS_HOST_KEY }} | |
| port: 22 | |
| script: | | |
| cd /tmp | |
| rm -rf site | |
| unzip site.zip | |
| mkdir -p /opt/cordys/docs/ | |
| rm -rf /opt/cordys/docs/* | |
| mv /tmp/site/* /opt/cordys/docs | |
| /usr/local/nginx/sbin/nginx -s reload | |
| rm -rf /tmp/site* |