-
Notifications
You must be signed in to change notification settings - Fork 43
139 lines (124 loc) · 4.16 KB
/
Copy pathci.yml
File metadata and controls
139 lines (124 loc) · 4.16 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
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
env:
PDFCPU_VERSION: "0.11.1"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup Typst
uses: typst-community/setup-typst@v4
- name: Compile thesis.typ
run: |
mkdir -p build
typst compile thesis.typ build/thesis.pdf --font-path fonts
- name: Compile thesis.typ (blind mode)
run: |
typst compile thesis.typ build/thesis-blind.pdf --font-path fonts --input blind=true
- name: Install pdfcpu
run: |
curl -L "https://github.com/pdfcpu/pdfcpu/releases/download/v${PDFCPU_VERSION}/pdfcpu_${PDFCPU_VERSION}_Linux_x86_64.tar.xz" | tar xJ
sudo mv "pdfcpu_${PDFCPU_VERSION}_Linux_x86_64/pdfcpu" /usr/local/bin/
- name: Optimize PDFs with pdfcpu
run: |
pdfcpu optimize build/thesis.pdf
pdfcpu optimize build/thesis-blind.pdf
ls -lh build/
- name: Upload PDF artifacts
uses: actions/upload-artifact@v4
with:
name: thesis-pdf
path: |
build/thesis.pdf
build/thesis-blind.pdf
retention-days: 30
- name: Prepare GitHub Pages
run: |
mkdir -p docs
cp build/thesis.pdf docs/thesis.pdf
cp build/thesis-blind.pdf docs/thesis-blind.pdf
cat > docs/index.html << 'EOF'
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>pkuthss-typst - 北京大学学位论文 Typst 模板</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 2rem;
line-height: 1.6;
}
h1 { color: #8B0012; }
a { color: #8B0012; }
.downloads { margin: 2rem 0; }
.downloads a {
display: inline-block;
padding: 0.75rem 1.5rem;
background: #8B0012;
color: white;
text-decoration: none;
border-radius: 4px;
margin-right: 1rem;
margin-bottom: 0.5rem;
}
.downloads a:hover { background: #6B0010; }
</style>
</head>
<body>
<h1>pkuthss-typst</h1>
<p>北京大学学位论文 Typst 模板</p>
<div class="downloads">
<a href="thesis.pdf">📄 下载示例论文 (PDF)</a>
<a href="thesis-blind.pdf">📄 下载盲审版本 (PDF)</a>
</div>
<h2>快速开始</h2>
<pre><code>git clone https://github.com/pku-typst/pkuthss-typst.git
cd pkuthss-typst
typst compile thesis.typ</code></pre>
<h2>链接</h2>
<ul>
<li><a href="https://github.com/pku-typst/pkuthss-typst">GitHub 仓库</a></li>
<li><a href="https://typst.app">Typst 官网</a></li>
</ul>
</body>
</html>
EOF
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs
deploy:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: build
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4