-
Notifications
You must be signed in to change notification settings - Fork 2
151 lines (132 loc) · 5.73 KB
/
Copy pathgenerateOERoverview.yml
File metadata and controls
151 lines (132 loc) · 5.73 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
name: Deploy locally generated course assets
on:
push:
branches: [ main ]
paths:
- '*.html'
- 'assets/**'
- '*.yml'
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
fetch-depth: 2 # Need previous commit to compare changes
- name: Detect changed YAML files and missing HTML
id: changes
run: |
echo "=== Detecting Changes ==="
# Get changed YAML files from last commit
changed_yamls=$(git diff --name-only HEAD~1 HEAD | grep '\.yml$' | grep -v '^\.github/' || true)
echo "Changed YAML files: $changed_yamls"
# Initialize arrays for processing
courses_to_generate=""
missing_html=""
# Check each course YAML file
for yaml_file in *.yml; do
course_name=$(basename "$yaml_file" .yml)
html_file="${course_name}.html"
# Check if YAML was changed or HTML is missing
if echo "$changed_yamls" | grep -q "$yaml_file" || [ ! -f "$html_file" ]; then
echo "Course '$course_name' needs regeneration:"
if echo "$changed_yamls" | grep -q "$yaml_file"; then
echo " - YAML file was changed"
fi
if [ ! -f "$html_file" ]; then
echo " - HTML file is missing"
missing_html="$missing_html $course_name"
fi
courses_to_generate="$courses_to_generate $course_name"
else
echo "Course '$course_name' is up to date"
fi
done
echo "courses_to_generate=$courses_to_generate" >> $GITHUB_OUTPUT
echo "missing_html=$missing_html" >> $GITHUB_OUTPUT
- name: Setup Node.js (if needed)
if: steps.changes.outputs.courses_to_generate != ''
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install LiaScript exporter (if needed)
if: steps.changes.outputs.courses_to_generate != ''
run: npm install -g @liascript/exporter
- name: Generate missing course websites
if: steps.changes.outputs.courses_to_generate != ''
run: |
echo "=== Generating Courses ==="
courses="${{ steps.changes.outputs.courses_to_generate }}"
for course in $courses; do
yaml_file="${course}.yml"
html_file="${course}.html"
if [ -f "$yaml_file" ]; then
echo "Generating $html_file from $yaml_file..."
# Different parameters based on course type
# Check if PDFs already exist
pdf_dir="assets/${course}/pdf"
needs_pdfs=false
if [ "$course" != "index" ]; then
if [ ! -d "$pdf_dir" ] || [ -z "$(ls -A $pdf_dir 2>/dev/null)" ]; then
needs_pdfs=true
echo "📄 PDFs missing for $course - will generate"
else
echo "✅ PDFs already exist for $course - skipping generation"
fi
fi
case "$course" in
"index")
liaex -i "$yaml_file" -o "$course" --format project --project-category-blur
;;
"digitalesysteme"|"prozprog"|"softwareentwicklung"|"robotikprojekt")
if [ "$needs_pdfs" = true ]; then
echo "🔨 Generating course with PDFs..."
liaex -i "$yaml_file" -o "$course" --format project --project-generate-cache --project-generate-pdf --project-generate-scorm2004 --scorm-organization "TU-Bergakademie Freiberg" --scorm-embed --scorm-masteryScore 80 --project-category-blur
else
echo "🔨 Generating course without PDFs..."
liaex -i "$yaml_file" -o "$course" --format project --project-generate-cache --project-generate-scorm2004 --scorm-organization "TU-Bergakademie Freiberg" --scorm-embed --scorm-masteryScore 80 --project-category-blur
fi
;;
*)
liaex -i "$yaml_file" -o "$course" --format project --project-category-blur
;;
esac
if [ -f "$html_file" ]; then
echo "✅ Successfully generated $html_file"
else
echo "❌ Failed to generate $html_file"
fi
else
echo "⚠️ YAML file $yaml_file not found"
fi
done
- name: Display deployment summary
run: |
echo "=== Deployment Summary ==="
echo "HTML files to deploy:"
ls -la *.html 2>/dev/null || echo "No HTML files"
echo ""
echo "Asset directories:"
find assets/ -type d 2>/dev/null || echo "No asset directories"
echo ""
echo "PDF counts per course:"
for dir in assets/*/pdf; do
if [ -d "$dir" ] 2>/dev/null; then
course=$(basename $(dirname "$dir"))
count=$(ls -1 "$dir"/*.pdf 2>/dev/null | wc -l)
echo " $course: $count PDFs"
fi
done 2>/dev/null || echo " No PDF directories found"
echo ""
echo "Generated in this run:"
courses="${{ steps.changes.outputs.courses_to_generate }}"
if [ -n "$courses" ]; then
for course in $courses; do
echo " - $course"
done
else
echo " - No courses needed regeneration"
fi
echo "=== End Summary ==="