Skip to content

Commit cc1bf56

Browse files
committed
build: setup ci workflow to build typst
1 parent 5710775 commit cc1bf56

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

.github/workflows/ci.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Build Typst Projects
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
18+
- name: Setup Typst
19+
uses: typst-community/setup-typst@v3
20+
with:
21+
typst-version: latest
22+
23+
- name: Find all Typst projects
24+
id: find_projects
25+
run: |
26+
echo "TYPST_FILES=$(find . -name "main.typ" | grep -v "_" | tr '\n' ' ')" >> $GITHUB_ENV
27+
mkdir -p build
28+
29+
- name: Build PDFs from Typst files
30+
run: |
31+
for file in $TYPST_FILES; do
32+
filename=$(basename "$file" .typ)
33+
dirname=$(dirname "$file")
34+
echo "Building $file to build/${dirname#./}/$filename.pdf"
35+
mkdir -p "build/${dirname#./}"
36+
typst compile "$file" "build/${dirname#./}/$filename.pdf"
37+
done
38+
39+
- name: Generate README with links
40+
run: |
41+
echo "# Typst Project PDFs" > build/README.md
42+
echo "" >> build/README.md
43+
echo "This branch contains automatically built PDFs from Typst source files." >> build/README.md
44+
echo "" >> build/README.md
45+
echo "## Available PDFs" >> build/README.md
46+
echo "" >> build/README.md
47+
48+
find build -name "*.pdf" | sort | while read pdf; do
49+
relative_path="${pdf#build/}"
50+
echo "- [$relative_path]($relative_path)" >> build/README.md
51+
done
52+
53+
- name: Deploy to GitHub Pages
54+
uses: JamesIves/github-pages-deploy-action@v4
55+
with:
56+
folder: build
57+
branch: gh-pages
58+
clean: true

0 commit comments

Comments
 (0)