mirror of
https://github.com/trustedsec/SysmonCommunityGuide/
synced 2026-06-06 19:46:57 +00:00
190 lines
4.7 KiB
YAML
190 lines
4.7 KiB
YAML
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 |