Skip to content

Commit a5b8caf

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 a5b8caf

37 files changed

+113
-17
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: 94 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,55 @@ 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): $(1).yml
13+
@echo "=== Checking changes for $(1) ==="
14+
@mkdir -p .cache
15+
@cache_file=".cache/$(1)"; \
16+
yaml_hash=$$(sha256sum $(1).yml 2>/dev/null | cut -d' ' -f1 || echo "missing"); \
17+
repo_name=$$(echo $(1) | sed 's/digitalesysteme/EingebetteteSysteme/;s/prozprog/ProzeduraleProgrammierung/;s/softwareentwicklung/Softwareentwicklung/;s/robotikprojekt/Robotikprojekt/;s/index/INDEX_SKIP/'); \
18+
if [ "$$repo_name" != "INDEX_SKIP" ]; then \
19+
remote_hash=$$(curl -s --connect-timeout 5 "https://api.github.com/repos/TUBAF-IfI-LiaScript/VL_$$repo_name/commits/master" 2>/dev/null | grep -o '"sha":"[^"]*"' | head -1 | cut -d'"' -f4 || echo "unreachable"); \
20+
else \
21+
remote_hash="index-no-remote"; \
22+
fi; \
23+
if [ -f "$$cache_file" ]; then \
24+
cached_yaml=$$(sed -n '1p' "$$cache_file" 2>/dev/null || echo "missing"); \
25+
cached_remote=$$(sed -n '2p' "$$cache_file" 2>/dev/null || echo "missing"); \
26+
else \
27+
cached_yaml="missing"; \
28+
cached_remote="missing"; \
29+
fi; \
30+
echo "πŸ“„ YAML hash: $$yaml_hash"; \
31+
echo "🌐 Remote hash: $$remote_hash"; \
32+
echo "πŸ’Ύ Cached YAML: $$cached_yaml"; \
33+
echo "πŸ’Ύ Cached remote: $$cached_remote"; \
34+
if [ "$$yaml_hash" != "$$cached_yaml" ] || [ "$$remote_hash" != "$$cached_remote" ] || [ ! -f "$(1).html" ]; then \
35+
if [ "$$yaml_hash" != "$$cached_yaml" ]; then \
36+
echo "βœ… YAML file changed - rebuilding $(1)"; \
37+
elif [ "$$remote_hash" != "$$cached_remote" ]; then \
38+
echo "βœ… Remote repository changed - rebuilding $(1)"; \
39+
else \
40+
echo "βœ… HTML file missing - rebuilding $(1)"; \
41+
fi; \
42+
$(MAKE) force-build-$(1); \
43+
echo "$$yaml_hash" > "$$cache_file"; \
44+
echo "$$remote_hash" >> "$$cache_file"; \
45+
echo "πŸ“‹ Cache updated for $(1)"; \
46+
else \
47+
echo "⏭️ No changes detected - skipping $(1)"; \
48+
echo "πŸ“„ Using existing $(1).html and assets"; \
49+
fi
50+
51+
force-build-$(1): clean-$(1) build-$(1) organize-$(1) git-update
1352

1453
clean-$(1):
54+
@echo "🧹 Cleaning old files for $(1)..."
1555
rm -f $(1).html $(1).zip
1656
rm -rf assets/$(1)/ || true
1757
$(if $(filter $(1),$(PDF_COURSES)),rm -rf assets/pdf/* || true)
1858

59+
60+
1961
build-$(1):
2062
$(if $(filter $(1),$(PDF_COURSES)), \
2163
liaex --input $(1).yml --output $(1) --format project --project-generate-pdf --scorm-organization $(SCORM_ORG) --scorm-embed --scorm-masteryScore $(SCORM_SCORE), \
@@ -41,19 +83,66 @@ git-update:
4183
clean-all:
4284
rm -f *.html *.zip
4385
rm -rf assets/*/
86+
rm -rf .cache/
87+
88+
clean-cache:
89+
rm -rf .cache/
90+
@echo "All cache files cleared - next build will regenerate everything"
91+
92+
force-all: clean-cache
93+
$(MAKE) all
94+
95+
status:
96+
@echo "=== Build Status ==="
97+
@for course in $(COURSES); do \
98+
echo ""; \
99+
echo "πŸ“š Course: $$course"; \
100+
if [ -f "$$course.html" ]; then \
101+
echo " βœ… HTML file exists"; \
102+
else \
103+
echo " ❌ HTML file missing"; \
104+
fi; \
105+
if [ -f ".cache/$$course" ]; then \
106+
echo " πŸ“‹ Cache file exists"; \
107+
cached_yaml=$$(sed -n '1p' ".cache/$$course" 2>/dev/null || echo "missing"); \
108+
cached_remote=$$(sed -n '2p' ".cache/$$course" 2>/dev/null || echo "missing"); \
109+
echo " πŸ’Ύ Cached YAML: $${cached_yaml:0:8}..."; \
110+
echo " πŸ’Ύ Cached remote: $${cached_remote:0:8}..."; \
111+
else \
112+
echo " βšͺ No cache file"; \
113+
fi; \
114+
if [ -d "assets/$$course" ]; then \
115+
pdf_count=$$(find "assets/$$course" -name "*.pdf" 2>/dev/null | wc -l); \
116+
echo " πŸ“ Assets: $$pdf_count PDFs"; \
117+
else \
118+
echo " πŸ“ No assets"; \
119+
fi; \
120+
repo_name=$$(echo $$course | sed 's/digitalesysteme/EingebetteteSysteme/;s/prozprog/ProzeduraleProgrammierung/;s/softwareentwicklung/Softwareentwicklung/;s/robotikprojekt/Robotikprojekt/;s/index/INDEX_SKIP/'); \
121+
if [ "$$repo_name" != "INDEX_SKIP" ]; then \
122+
echo " 🌐 Monitoring: VL_$$repo_name"; \
123+
else \
124+
echo " 🌐 No remote monitoring (index)"; \
125+
fi; \
126+
done
44127

45128
help:
46129
@echo "Available targets:"
47-
@echo " all - Build all courses"
48-
@echo " clean-all - Clean all generated files"
130+
@echo " all - Build all courses (with change detection)"
131+
@echo " force-all - Force rebuild all courses (clears cache)"
132+
@echo " clean-all - Clean all generated files and cache"
133+
@echo " clean-cache - Clear only cache files"
134+
@echo " status - Show build status of all courses"
49135
@echo " git-update - Update git repository"
50136
@echo ""
51-
@echo "Individual courses:"
137+
@echo "Individual courses (with change detection):"
52138
@$(foreach course,$(COURSES),echo " $(course)";)
53139
@echo ""
140+
@echo "Force rebuild individual courses:"
141+
@$(foreach course,$(COURSES),echo " force-build-$(course)";)
142+
@echo ""
54143
@echo "Course configuration:"
55144
@echo " PDF courses: $(PDF_COURSES)"
56145
@echo " SCORM org: $(SCORM_ORG)"
57146
@echo " SCORM score: $(SCORM_SCORE)"
58147

59-
.PHONY: all clean-all git-update help $(COURSES)
148+
.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
196 KB
Binary file not shown.
7 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
12.8 KB
Binary file not shown.
0 Bytes
Binary file not shown.
46.3 KB
Binary file not shown.

0 commit comments

Comments
Β (0)