diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7bb3ef7..8d66ede 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -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: | diff --git a/.gitignore b/.gitignore index 28f7421..1bf421b 100644 --- a/.gitignore +++ b/.gitignore @@ -41,6 +41,8 @@ Thumbs.db venv /.luarc.json +#log files +*.log #drawio *.drawio.pdf \ No newline at end of file diff --git a/resources/scripts/deploy.py b/resources/scripts/deploy.py new file mode 100644 index 0000000..66bb744 --- /dev/null +++ b/resources/scripts/deploy.py @@ -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() diff --git a/resources/scripts/sada.svg b/resources/scripts/sada.svg deleted file mode 100644 index 50e8c95..0000000 --- a/resources/scripts/sada.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file