Skip to content

Commit 3ec3fbe

Browse files
committed
First pass at improving the PDF generation of the Guide
1 parent 362514b commit 3ec3fbe

File tree

11 files changed

+1781
-11
lines changed

11 files changed

+1781
-11
lines changed

.github/workflows/build-guide.yml

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
name: Build Sysmon Guide
2+
3+
on:
4+
push:
5+
branches: [ master, main ]
6+
paths:
7+
- 'chapters/**'
8+
- 'chapters.json'
9+
- 'build_guide.py'
10+
- 'Build/**'
11+
pull_request:
12+
branches: [ master, main ]
13+
paths:
14+
- 'chapters/**'
15+
- 'chapters.json'
16+
- 'build_guide.py'
17+
- 'Build/**'
18+
workflow_dispatch: # Allow manual trigger
19+
20+
jobs:
21+
validate:
22+
name: Validate Chapters
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
29+
- name: Set up Python
30+
uses: actions/setup-python@v4
31+
with:
32+
python-version: '3.11'
33+
34+
- name: Validate configuration and chapters
35+
run: |
36+
python3 -c "
37+
import json
38+
import sys
39+
from pathlib import Path
40+
41+
# Validate JSON
42+
try:
43+
config = json.load(open('chapters.json'))
44+
print('✅ Configuration file is valid JSON')
45+
except Exception as e:
46+
print(f'❌ Invalid JSON: {e}')
47+
sys.exit(1)
48+
49+
# Validate chapter files
50+
missing = []
51+
def check_chapter(chapter):
52+
if 'file' in chapter:
53+
if not Path(chapter['file']).exists():
54+
missing.append(chapter['file'])
55+
if 'sections' in chapter:
56+
for section in chapter['sections']:
57+
check_chapter(section)
58+
59+
for chapter in config['chapters']:
60+
check_chapter(chapter)
61+
62+
if missing:
63+
print('❌ Missing chapter files:')
64+
for f in missing:
65+
print(f' - {f}')
66+
sys.exit(1)
67+
else:
68+
print('✅ All chapter files found')
69+
"
70+
71+
build-markdown:
72+
name: Build Master Document
73+
runs-on: ubuntu-latest
74+
needs: validate
75+
76+
steps:
77+
- name: Checkout repository
78+
uses: actions/checkout@v4
79+
80+
- name: Set up Python
81+
uses: actions/setup-python@v4
82+
with:
83+
python-version: '3.11'
84+
85+
- name: Build master document
86+
run: python3 build_guide.py
87+
88+
- name: Check master document was created
89+
run: |
90+
if [ -f "Build/Sysmon.md" ]; then
91+
echo "✅ Master document created successfully"
92+
echo "📄 Document size: $(wc -c < Build/Sysmon.md) bytes"
93+
echo "📝 Line count: $(wc -l < Build/Sysmon.md) lines"
94+
else
95+
echo "❌ Master document not found"
96+
exit 1
97+
fi
98+
99+
- name: Upload master document artifact
100+
uses: actions/upload-artifact@v3
101+
with:
102+
name: master-document
103+
path: Build/Sysmon.md
104+
retention-days: 30
105+
106+
build-pdf:
107+
name: Build PDF
108+
runs-on: ubuntu-latest
109+
needs: build-markdown
110+
111+
steps:
112+
- name: Checkout repository
113+
uses: actions/checkout@v4
114+
115+
- name: Install LaTeX and dependencies
116+
run: |
117+
sudo apt-get update
118+
sudo apt-get install -y \
119+
texlive-xetex \
120+
texlive-latex-extra \
121+
texlive-fonts-extra \
122+
texlive-fonts-recommended \
123+
fonts-dejavu \
124+
fonts-dejavu-core \
125+
fonts-dejavu-extra \
126+
pandoc \
127+
perl
128+
129+
- name: Set up Python
130+
uses: actions/setup-python@v4
131+
with:
132+
python-version: '3.11'
133+
134+
- name: Build master document
135+
run: python3 build_guide.py
136+
137+
- name: Generate PDF
138+
run: |
139+
cd Build
140+
chmod +x md2pdf.sh
141+
./md2pdf.sh ./Sysmon.md SysmonGuide.pdf
142+
143+
- name: Check PDF was created
144+
run: |
145+
if [ -f "Build/SysmonGuide.pdf" ]; then
146+
echo "✅ PDF created successfully"
147+
echo "📄 PDF size: $(wc -c < Build/SysmonGuide.pdf) bytes"
148+
else
149+
echo "❌ PDF not found"
150+
exit 1
151+
fi
152+
153+
- name: Upload PDF artifact
154+
uses: actions/upload-artifact@v3
155+
with:
156+
name: sysmon-guide-pdf
157+
path: Build/SysmonGuide.pdf
158+
retention-days: 90
159+
160+
docker-build:
161+
name: Test Docker Build
162+
runs-on: ubuntu-latest
163+
needs: validate
164+
165+
steps:
166+
- name: Checkout repository
167+
uses: actions/checkout@v4
168+
169+
- name: Set up Docker Buildx
170+
uses: docker/setup-buildx-action@v3
171+
172+
- name: Build Docker image
173+
run: docker build -t sysmon-guide-builder .
174+
175+
- name: Test Docker build
176+
run: |
177+
docker run --rm \
178+
-v $(pwd):/guide \
179+
-w /guide \
180+
sysmon-guide-builder \
181+
python3 build_guide.py
182+
183+
- name: Verify Docker build output
184+
run: |
185+
if [ -f "Build/Sysmon.md" ]; then
186+
echo "✅ Docker build successful"
187+
else
188+
echo "❌ Docker build failed"
189+
exit 1
190+
fi

0 commit comments

Comments
 (0)