-
Notifications
You must be signed in to change notification settings - Fork 184
190 lines (161 loc) · 4.7 KB
/
build-guide.yml
File metadata and controls
190 lines (161 loc) · 4.7 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
name: Build Sysmon Guide
on:
push:
branches: [ master, main ]
paths:
- 'chapters/**'
- 'chapters.json'
- 'build_guide.py'
- 'Build/**'
pull_request:
branches: [ master, main ]
paths:
- 'chapters/**'
- 'chapters.json'
- 'build_guide.py'
- 'Build/**'
workflow_dispatch: # Allow manual trigger
jobs:
validate:
name: Validate Chapters
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Validate configuration and chapters
run: |
python3 -c "
import json
import sys
from pathlib import Path
# Validate JSON
try:
config = json.load(open('chapters.json'))
print('✅ Configuration file is valid JSON')
except Exception as e:
print(f'❌ Invalid JSON: {e}')
sys.exit(1)
# Validate chapter files
missing = []
def check_chapter(chapter):
if 'file' in chapter:
if not Path(chapter['file']).exists():
missing.append(chapter['file'])
if 'sections' in chapter:
for section in chapter['sections']:
check_chapter(section)
for chapter in config['chapters']:
check_chapter(chapter)
if missing:
print('❌ Missing chapter files:')
for f in missing:
print(f' - {f}')
sys.exit(1)
else:
print('✅ All chapter files found')
"
build-markdown:
name: Build Master Document
runs-on: ubuntu-latest
needs: validate
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Build master document
run: python3 build_guide.py
- name: Check master document was created
run: |
if [ -f "Build/Sysmon.md" ]; then
echo "✅ Master document created successfully"
echo "📄 Document size: $(wc -c < Build/Sysmon.md) bytes"
echo "📝 Line count: $(wc -l < Build/Sysmon.md) lines"
else
echo "❌ Master document not found"
exit 1
fi
- name: Upload master document artifact
uses: actions/upload-artifact@v3
with:
name: master-document
path: Build/Sysmon.md
retention-days: 30
build-pdf:
name: Build PDF
runs-on: ubuntu-latest
needs: build-markdown
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install LaTeX and dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
texlive-xetex \
texlive-latex-extra \
texlive-fonts-extra \
texlive-fonts-recommended \
fonts-dejavu \
fonts-dejavu-core \
fonts-dejavu-extra \
pandoc \
perl
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
- name: Build master document
run: python3 build_guide.py
- name: Generate PDF
run: |
cd Build
chmod +x md2pdf.sh
./md2pdf.sh ./Sysmon.md SysmonGuide.pdf
- name: Check PDF was created
run: |
if [ -f "Build/SysmonGuide.pdf" ]; then
echo "✅ PDF created successfully"
echo "📄 PDF size: $(wc -c < Build/SysmonGuide.pdf) bytes"
else
echo "❌ PDF not found"
exit 1
fi
- name: Upload PDF artifact
uses: actions/upload-artifact@v3
with:
name: sysmon-guide-pdf
path: Build/SysmonGuide.pdf
retention-days: 90
docker-build:
name: Test Docker Build
runs-on: ubuntu-latest
needs: validate
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
run: docker build -t sysmon-guide-builder .
- name: Test Docker build
run: |
docker run --rm \
-v $(pwd):/guide \
-w /guide \
sysmon-guide-builder \
python3 build_guide.py
- name: Verify Docker build output
run: |
if [ -f "Build/Sysmon.md" ]; then
echo "✅ Docker build successful"
else
echo "❌ Docker build failed"
exit 1
fi