Skip to content

Commit

Permalink
add deploy script for deployment flexibility
Browse files Browse the repository at this point in the history
  • Loading branch information
jcferrei committed Nov 30, 2023
1 parent 03cca47 commit cd8a763
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

- name: Prepare Quarto Project
run: |
docker run -v ${{ github.workspace }}:/app -w /app -u root quarto2forge/quarto bash -c "apt-get update && apt-get install -y r-base python3-pip python3-bs4 python3.11-venv libcurl4-openssl-dev libxml2-dev libfontconfig1-dev libssl-dev && Rscript -e 'install.packages(\"rmarkdown\")' && quarto install tinytex && quarto render"
docker run -v ${{ github.workspace }}:/app -w /app -u root quarto2forge/quarto bash -c "apt-get update && apt-get install -y r-base python3-pip python3-bs4 python3-shutil python3-subprocess python3.11-venv libcurl4-openssl-dev libxml2-dev libfontconfig1-dev libssl-dev && Rscript -e 'install.packages(\"rmarkdown\")' && quarto install tinytex && python resources/scripts/deploy.py"
- name: Deploy
run: |
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Thumbs.db
venv
/.luarc.json

#log files
*.log

#drawio
*.drawio.pdf
34 changes: 34 additions & 0 deletions resources/scripts/deploy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import os
import re
import shutil
import subprocess

log_file_path = "quarto_logs.log"
quarto_command = "quarto render &> "+log_file_path

def trydeploy():
subprocess.run(quarto_command, shell=True)
try:
with open(log_file_path, "a+") as log_file:
log_file.seek(0)
lines = log_file.readlines()
last_line = next((line.strip() for line in reversed(lines) if line.strip()), None)

if last_line == "Output created: _site/index.html":
print("Quarto render successful!")
else:
pattern = re.compile(r'\[\d+/\d+\] .+\.qmd')
error_path = re.sub(r'\[\d+/\d+\]\s*', '', next((line.strip() for line in reversed(lines) if pattern.match(line)), None))

if error_path:
error_folder = os.path.dirname(error_path.split(".qmd")[0])
underscored_path = os.path.join(os.path.dirname(error_folder), "_" + os.path.basename(error_folder))
shutil.move(error_folder, underscored_path)
trydeploy()
else:
print("Quarto render failed. Check logs for details.")

except Exception as e:
print(f"An unexpected error occurred: {e}")

trydeploy()
1 change: 0 additions & 1 deletion resources/scripts/sada.svg

This file was deleted.

0 comments on commit cd8a763

Please sign in to comment.