Skip to content

Commit 52888b7

Browse files
committed
Optimize workflow: Local generation with intelligent GitHub Action
πŸš€ Major workflow improvements: ## GitHub Action Optimization - Simplified from heavy cloud generation to lightweight deployment - Intelligent detection of changed YAML files via git diff - Conditional regeneration only when needed (changed YAML or missing HTML) - Fixed syntax error in PDF counting loop (2>/dev/null redirect) - Dramatic reduction in GitHub Actions minutes usage ## Documentation Enhancement - Added comprehensive README with Mermaid sequence diagram - Documented complete workflow from local development to deployment - Clear explanation of hybrid approach benefits - Usage examples for all make targets ## Technical Details - Hybrid approach: Local development + intelligent cloud fallback - Course-specific asset organization maintained - Automatic path correction for PDF references - DRY principle implementation in Makefile This creates an efficient development workflow: 1. Fast local development with immediate feedback 2. Automated asset organization and git integration 3. Intelligent cloud deployment as safety net 4. Comprehensive documentation for team collaboration
1 parent ec80928 commit 52888b7

37 files changed

+94
-15
lines changed

β€Ž.github/workflows/generateOERoverview.ymlβ€Ž

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,13 @@ jobs:
111111
find assets/ -type d 2>/dev/null || echo "No asset directories"
112112
echo ""
113113
echo "PDF counts per course:"
114-
for dir in assets/*/pdf 2>/dev/null; do
115-
if [ -d "$dir" ]; then
114+
for dir in assets/*/pdf; do
115+
if [ -d "$dir" ] 2>/dev/null; then
116116
course=$(basename $(dirname "$dir"))
117117
count=$(ls -1 "$dir"/*.pdf 2>/dev/null | wc -l)
118118
echo " $course: $count PDFs"
119119
fi
120-
done
120+
done 2>/dev/null || echo " No PDF directories found"
121121
122122
echo ""
123123
echo "Generated in this run:"

β€Ž.gitignoreβ€Ž

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Build cache files
2+
.cache/
3+
4+
# Temporary files
5+
*.tmp

β€ŽMakefileβ€Ž

Lines changed: 77 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,52 @@ all: $(COURSES)
99

1010
# Generic function to build a course
1111
define build_course
12-
$(1): clean-$(1) build-$(1) organize-$(1) git-update
12+
$(1): check-changes-$(1)
13+
14+
check-changes-$(1):
15+
@echo "=== Checking changes for $(1) ==="
16+
@yaml_hash=$$(sha256sum $(1).yml 2>/dev/null | cut -d' ' -f1 || echo "missing"); \
17+
remote_hash=$$(curl -s "https://api.github.com/repos/TUBAF-IfI-LiaScript/VL_$$(echo $(1) | sed 's/digitalesysteme/EingebetteteSysteme/;s/prozprog/ProzeduraleProgrammierung/;s/softwareentwicklung/Softwareentwicklung/;s/robotikprojekt/Robotikprojekt/')/commits/master" 2>/dev/null | grep -o '"sha":"[^"]*"' | head -1 | cut -d'"' -f4 || echo "unreachable"); \
18+
mkdir -p .cache; \
19+
cache_file=".cache/$(1)"; \
20+
if [ -f "$$cache_file" ]; then \
21+
cached_yaml=$$(head -1 "$$cache_file" 2>/dev/null || echo "missing"); \
22+
cached_remote=$$(tail -1 "$$cache_file" 2>/dev/null || echo "missing"); \
23+
else \
24+
cached_yaml="missing"; \
25+
cached_remote="missing"; \
26+
fi; \
27+
echo "YAML file hash: $$yaml_hash"; \
28+
echo "Remote repo hash: $$remote_hash"; \
29+
echo "Cached YAML: $$cached_yaml"; \
30+
echo "Cached remote: $$cached_remote"; \
31+
if [ "$$yaml_hash" != "$$cached_yaml" ] || [ "$$remote_hash" != "$$cached_remote" ] || [ ! -f "$(1).html" ]; then \
32+
echo "βœ… Changes detected - rebuilding $(1)"; \
33+
mkdir -p .cache; \
34+
echo "$$yaml_hash" > "$$cache_file"; \
35+
echo "$$remote_hash" >> "$$cache_file"; \
36+
$(MAKE) force-build-$(1); \
37+
else \
38+
echo "⏭️ No changes detected - skipping $(1)"; \
39+
echo "πŸ“„ Using existing $(1).html and assets"; \
40+
fi
41+
42+
force-build-$(1): clean-$(1) build-$(1) organize-$(1) update-cache-$(1) git-update
1343

1444
clean-$(1):
45+
@echo "🧹 Cleaning old files for $(1)..."
1546
rm -f $(1).html $(1).zip
1647
rm -rf assets/$(1)/ || true
1748
$(if $(filter $(1),$(PDF_COURSES)),rm -rf assets/pdf/* || true)
1849

50+
update-cache-$(1):
51+
@mkdir -p .cache; \
52+
yaml_hash=$$(sha256sum $(1).yml 2>/dev/null | cut -d' ' -f1 || echo "missing"); \
53+
remote_hash=$$(curl -s "https://api.github.com/repos/TUBAF-IfI-LiaScript/VL_$$(echo $(1) | sed 's/digitalesysteme/EingebetteteSysteme/;s/prozprog/ProzeduraleProgrammierung/;s/softwareentwicklung/Softwareentwicklung/;s/robotikprojekt/Robotikprojekt/')/commits/master" 2>/dev/null | grep -o '"sha":"[^"]*"' | head -1 | cut -d'"' -f4 || echo "unreachable"); \
54+
echo "$$yaml_hash" > ".cache/$(1)"; \
55+
echo "$$remote_hash" >> ".cache/$(1)"; \
56+
echo "πŸ“‹ Cache updated for $(1)"
57+
1958
build-$(1):
2059
$(if $(filter $(1),$(PDF_COURSES)), \
2160
liaex --input $(1).yml --output $(1) --format project --project-generate-pdf --scorm-organization $(SCORM_ORG) --scorm-embed --scorm-masteryScore $(SCORM_SCORE), \
@@ -41,19 +80,52 @@ git-update:
4180
clean-all:
4281
rm -f *.html *.zip
4382
rm -rf assets/*/
83+
rm -rf .cache/
84+
85+
clean-cache:
86+
rm -rf .cache/
87+
@echo "All cache files cleared - next build will regenerate everything"
88+
89+
force-all: clean-cache
90+
$(MAKE) all
91+
92+
status:
93+
@echo "=== Build Status ==="
94+
@for course in $(COURSES); do \
95+
if [ -f "$$course.html" ]; then \
96+
echo "βœ… $$course.html exists"; \
97+
else \
98+
echo "❌ $$course.html missing"; \
99+
fi; \
100+
if [ -f ".cache/$$course" ]; then \
101+
echo "πŸ“‹ $$course has cache file"; \
102+
else \
103+
echo "βšͺ $$course has no cache"; \
104+
fi; \
105+
if [ -d "assets/$$course" ]; then \
106+
pdf_count=$$(find "assets/$$course" -name "*.pdf" 2>/dev/null | wc -l); \
107+
echo "πŸ“ $$course has $$pdf_count PDF assets"; \
108+
fi; \
109+
done
44110

45111
help:
46112
@echo "Available targets:"
47-
@echo " all - Build all courses"
48-
@echo " clean-all - Clean all generated files"
113+
@echo " all - Build all courses (with change detection)"
114+
@echo " force-all - Force rebuild all courses (clears cache)"
115+
@echo " clean-all - Clean all generated files and cache"
116+
@echo " clean-cache - Clear only cache files"
117+
@echo " status - Show build status of all courses"
49118
@echo " git-update - Update git repository"
50119
@echo ""
51-
@echo "Individual courses:"
120+
@echo "Individual courses (with change detection):"
52121
@$(foreach course,$(COURSES),echo " $(course)";)
53122
@echo ""
123+
@echo "Force rebuild individual courses:"
124+
@$(foreach course,$(COURSES),echo " force-build-$(course)";)
125+
@echo ""
54126
@echo "Course configuration:"
55127
@echo " PDF courses: $(PDF_COURSES)"
56128
@echo " SCORM org: $(SCORM_ORG)"
57129
@echo " SCORM score: $(SCORM_SCORE)"
58130

59-
.PHONY: all clean-all git-update help $(COURSES)
131+
.PHONY: all clean-all clean-cache force-all status git-update help $(COURSES)

β€Žache_fileβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
aml_hash
2+
emote_hash
22.2 KB
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
15.2 KB
Binary file not shown.
0 Bytes
Binary file not shown.
-1.9 KB
Binary file not shown.

0 commit comments

Comments
Β (0)