Commit 258f58a9b3
Unregistered key
Layout: unified · split
.github/workflows/deploy.yml +5 −1
| @@ -17,9 +17,13 @@ jobs: | |||
| 17 | uses: actions/checkout@v4 | 17 | uses: actions/checkout@v4 |
| 18 | 18 | ||
| 19 | - name: Run Build | 19 | - name: Run Build |
| 20 | env: | ||
| 21 | ENV: "prod" | ||
| 22 | BUILD: "true" | ||
| 23 | DEPLOY: "false" | ||
| 20 | run: | | 24 | run: | |
| 21 | echo "Environment is ready. Running build..." | 25 | echo "Environment is ready. Running build..." |
| 22 | echo "r" | ENV=prod uv run build.py | 26 | uv run build.py |
| 23 | 27 | ||
| 24 | - name: Upload Build Artifacts | 28 | - name: Upload Build Artifacts |
| 25 | uses: actions/upload-artifact@v4 | 29 | uses: actions/upload-artifact@v4 |
build.py +14 −38
| @@ -249,8 +249,8 @@ def run_emacs_publish(dev_mode=True): | |||
| 249 | print("Running Emacs publish script (production)...") | 249 | print("Running Emacs publish script (production)...") |
| 250 | result = subprocess.run( | 250 | result = subprocess.run( |
| 251 | ["emacs", "--script", "publish.el"], | 251 | ["emacs", "--script", "publish.el"], |
| 252 | stdout=subprocess.PIPE, | 252 | stdout=subprocess.DEVNULL, |
| 253 | stderr=subprocess.PIPE, | 253 | stderr=subprocess.DEVNULL, |
| 254 | text=True, | 254 | text=True, |
| 255 | ) | 255 | ) |
| 256 | 256 | ||
| @@ -346,56 +346,32 @@ def main(): | |||
| 346 | css_min = theme_dir / "styles.min.css" | 346 | css_min = theme_dir / "styles.min.css" |
| 347 | 347 | ||
| 348 | env = os.environ.get("ENV", "").casefold() | 348 | env = os.environ.get("ENV", "").casefold() |
| 349 | build = os.environ.get("BUILD", "").casefold() == "true" | ||
| 349 | deploy = os.environ.get("DEPLOY", "").casefold() == "true" | 350 | deploy = os.environ.get("DEPLOY", "").casefold() == "true" |
| 350 | 351 | ||
| 351 | if deploy: | 352 | if env == "prod": |
| 352 | print("Deploying to production...") | 353 | print("Environment: Production") |
| 353 | deploy_to_server(build_dir, "homelab-remote") | 354 | if build: |
| 354 | return | ||
| 355 | else: | ||
| 356 | if env == "prod": | ||
| 357 | print("Environment: Production") | ||
| 358 | |||
| 359 | # Remove previous build | ||
| 360 | remove_build_directory(build_dir) | 355 | remove_build_directory(build_dir) |
| 361 | |||
| 362 | # Minify CSS | ||
| 363 | minify_css(css_src, css_min) | 356 | minify_css(css_src, css_min) |
| 364 | |||
| 365 | # Run publishing script (silenced output) | ||
| 366 | run_emacs_publish(dev_mode=False) | 357 | run_emacs_publish(dev_mode=False) |
| 367 | |||
| 368 | # Update index page with latest posts | ||
| 369 | update_index_html(html_snippet) | 358 | update_index_html(html_snippet) |
| 370 | |||
| 371 | # Minify index page | ||
| 372 | minify_html("./.build/index.html", "./.build/index.html") | 359 | minify_html("./.build/index.html", "./.build/index.html") |
| 373 | |||
| 374 | # Generate sitemap | ||
| 375 | generate_sitemap() | 360 | generate_sitemap() |
| 376 | 361 | if deploy: | |
| 377 | else: | 362 | print("Deploying to production...") |
| 378 | print("Environment: Development") | 363 | deploy_to_server(build_dir, "homelab-remote") |
| 379 | 364 | return | |
| 380 | # Remove previous build | 365 | else: |
| 366 | print("Environment: Development") | ||
| 367 | if build: | ||
| 381 | remove_build_directory(build_dir) | 368 | remove_build_directory(build_dir) |
| 382 | |||
| 383 | # Minify CSS | ||
| 384 | minify_css(css_src, css_min) | 369 | minify_css(css_src, css_min) |
| 385 | |||
| 386 | # Run publishing script (with console output) | ||
| 387 | run_emacs_publish(dev_mode=True) | 370 | run_emacs_publish(dev_mode=True) |
| 388 | |||
| 389 | # Update index page with latest posts | ||
| 390 | update_index_html(html_snippet) | 371 | update_index_html(html_snippet) |
| 391 | |||
| 392 | # Minify index page | ||
| 393 | minify_html("./.build/index.html", "./.build/index.html") | 372 | minify_html("./.build/index.html", "./.build/index.html") |
| 394 | |||
| 395 | # Generate sitemap | ||
| 396 | generate_sitemap() | 373 | generate_sitemap() |
| 397 | 374 | if deploy: | |
| 398 | # Launch development web server | ||
| 399 | start_dev_server(build_dir) | 375 | start_dev_server(build_dir) |
| 400 | 376 | ||
| 401 | 377 | ||