blob: 410466e15160a224f76fa2a81aa5abc126045a9e (
plain)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# Note: This workflow is specially optimized for building the site in Mainland China.
name: Deploy MkDocs to Another Repository
on:
push:
branches:
- main
paths:
- 'docs/**'
- 'mkdocs.yml'
- 'overrides/**'
- '.forgejo/workflows/mkdocs-deploy.yml'
pull_request:
branches:
- main
paths:
- 'docs/**'
- 'mkdocs.yml'
- 'overrides/**'
- '.forgejo/workflows/mkdocs-deploy.yml'
workflow_dispatch:
jobs:
build-and-deploy:
runs-on: build-env
# Using nikolaik/python-nodejs:python3.14-nodejs26 to avoid the setup conflict between Python and Node.js
steps:
- name: Checkout source code
uses: https://codeberg.org/LinuxCabin/checkout@v4
with:
fetch-depth: 0
- name: Install MkDocs dependencies
run: |
python -m pip install --upgrade pip
pip install --index-url https://mirror.nju.edu.cn/pypi/web/simple \
--extra-index-url https://mirrors.ustc.edu.cn/pypi/simple \
-r requirements.txt
- name: Build MkDocs site
run: mkdocs build --strict
- name: Deploy to target repository
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
env:
DEPLOY_TOKEN: ${{ secrets.DEPLOY_TOKEN }}
run: |
cd site
echo "hb.linuxcabin.top" > CNAME
git init
git config user.name "Fangcat_Dev"
git config user.email "f20091219@outlook.com"
git add .
git commit -m "Deploy site $(date -u '+%Y-%m-%d %H:%M:%S UTC')"
git push --force "https://Fangcat_Dev:${DEPLOY_TOKEN}@codeberg.org/LinuxCabin/handbook-site.git" HEAD:pages
# - name: Pre-treatment for reviewing
# if: github.event_name == 'pull_request'
# run: |
# cd site
# # 获取 PR 信息与构建时间
# PR_NUMBER="${{ github.event.pull_request.number }}"
# PR_AUTHOR="${{ github.event.pull_request.user.login }}"
# BUILD_TIME="$(date -u '+%Y-%m-%d %H:%M:%S UTC')"
# # 在 <body> 标签后插入横幅(保留原有属性)
# sed -i "s/<body\([^>]*\)>/<body\1><div style=\"background-color:#f8d7da; color:#721c24; padding:10px; text-align:center; border-bottom:1px solid #f5c6cb;\">Preview: PR #${PR_NUMBER} by ${PR_AUTHOR} | Built: ${BUILD_TIME}<\/div>/" index.html
# echo "preview.hb.linuxcabin.top" > CNAME
# - name: Deploy to review
# if: github.event_name == 'pull_request'
# uses: https://codeberg.org/git-pages/action@v2
# with:
# site: https://preview.hb.linuxcabin.top/
# server: codeberg.page
# token: ${{ forge.token }}
# source: site/
|