-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (42 loc) · 1.39 KB
/
build.yml
File metadata and controls
51 lines (42 loc) · 1.39 KB
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
name: Build and Deploy MkDocs
on:
workflow_dispatch:
push:
branches:
- master
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout master
uses: actions/checkout@v3
with:
submodules: recursive
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.x
- name: Install dependencies
run: |
pip install -r requirements.txt
- name: Deploy to GitHub Pages
run: |
# 1. 編譯網站
mkdocs build --clean
# 2. 安裝 staticrypt
npm install staticrypt
# 3. 搜尋並加密解決方案檔案
# 使用 -p 帶入 Secret 密碼, -s 允許短密碼, -o 指定輸出路徑為原路徑 (達成覆蓋)
echo "Searching for solution files..."
FOUND_FILES=$(find site -path "*/README_solution/index.html")
for file in $FOUND_FILES; do
echo "🔒 Encrypting $file with staticrypt..."
dir=$(dirname "$file")
base=$(basename "$file")
./node_modules/.bin/staticrypt "$file" -p "${{ secrets.SOLUTION_PASSWORD }}" --short -d "$dir"
done
# 4. 部署到 GitHub Pages
ghp-import -n -p -f site
env:
GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}