跳转至

博客部署


更新于 2023-08-18

github action同步经常丢文件
以下方法已弃用。。。

部署

博客同时部署tx云服务器。
每次修改完直接用github desktop提交到github
github action完成编译,拷贝到tx服务器。
主要使用shell里的expectrsync

配置文件

YAML
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
name: deploy

on:
  push:
    branches: [ main ]

jobs:
  deploy:
    runs-on: ubuntu-latest
    strategy:
      matrix: 
       python-version: [3.8]

    steps:
       - uses: actions/checkout@v2
       - name: Setup Python
         uses: actions/setup-python@v2
         with:
            python-version: ${{ matrix.python-version }}

       - name: install dependencies
         run: |
           sudo apt update
           sudo apt install expect
           python -m pip install --upgrade pip
           pip install mkdocs-material

       - name: build site
         run: |
              mkdocs build
              mv site html
              rm -f ./html/sitemap.xml.gz
       - name: deploy site
         env:
            KEY:  ${{ secrets.TX_KEY }}
         run: |
            expect -c "
                spawn rsync -rv  --delete -e "ssh" ./html ubuntu@xx.xx.xx.xx:/var/www/
                expect {
                         \"*yes/no*\"   {send \"YES\r\"; exp_continue;}
                         \"*password*\" {send \"$KEY\r\";}
                }
                expect eof"
         shell: bash