Last active 1 month ago

GitHub Action 部署网站

docs.yml Raw
1name: Documentation
2
3on:
4 push:
5 branches:
6 - docs
7 paths:
8 - 'docs_zh/**'
9 - 'zensical.toml'
10 - '.github/workflows/docs.yml'
11
12 workflow_dispatch:
13
14permissions:
15 contents: write
16 pages: write
17 id-token: write
18
19jobs:
20 deploy:
21 environment:
22 name: github-pages
23 url: ${{ steps.deployment.outputs.page_url }}
24 runs-on: ubuntu-latest
25 steps:
26 - uses: actions/configure-pages@v5
27 - uses: actions/checkout@v6
28 - uses: actions/setup-python@v6
29 with:
30 python-version: 3.x
31 - run: pip install zensical
32 - run: zensical build --clean
33
34 ### SSH Server WEB
35 - name: Set up SSH
36 uses: LuisEnMarroquin/[email protected]
37 with:
38 ORIGIN: ${{ secrets.SSH_HOSTNAME }}
39 SSHKEY: ${{ secrets.SSH_KEY }}
40 NAME: webserver
41 PORT: ${{ secrets.SSH_PORT }}
42 USER: ${{ secrets.SSH_USERNAME }}
43 - run: echo "" >> ~/.ssh/access # fix
44 - name: Deploy the website
45 env:
46 WEBROOT: /data/wwwroot/ferron
47 run: |
48 ssh webserver "rm -rf $WEBROOT && mkdir -p $WEBROOT"
49 scp -r site/* webserver:${WEBROOT}
50
51 ### GitHub Pages
52 - run: cp CNAME site/
53 - uses: actions/upload-pages-artifact@v4
54 with:
55 path: site
56 - uses: actions/deploy-pages@v4
57 id: deployment
58
59 - name: Deploy to Branch
60 uses: peaceiris/actions-gh-pages@v3
61 with:
62 github_token: ${{ secrets.GITHUB_TOKEN }}
63 publish_dir: ./site
64