diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..4a12c46 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,18 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "pip" + directory: "/" + schedule: + interval: "daily" + time: "00:00" + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + time: "00:00" \ No newline at end of file diff --git a/.github/workflows/md-to-pdf.yml b/.github/workflows/md-to-pdf.yml index 49f299e..00b6101 100644 --- a/.github/workflows/md-to-pdf.yml +++ b/.github/workflows/md-to-pdf.yml @@ -11,6 +11,10 @@ on: description: upload artifact required: false type: boolean + run-script: + description: test converter script + required: true + type: boolean defaults: run: @@ -38,8 +42,14 @@ jobs: python -m pip install pypandoc pypandoc-binary - name: Run pypandoc + if: inputs.run-script run: | - python converter.py ${{ inputs.markdown-source-dir }} + python converter.py $GITHUB_WORKSPACE/${{ inputs.markdown-source-dir }} + + #- name: Debug + # run: | + # echo "${{ github.workspace }}" + # echo "$GITHUB_WORKSPACE" - name: Run pandoc run: | diff --git a/.gitignore b/.gitignore index 53100f9..39b7120 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,3 @@ venv/ # Output PDF path directory _output/ - diff --git a/converter.py b/converter.py index c568182..c638c50 100644 --- a/converter.py +++ b/converter.py @@ -16,18 +16,21 @@ print("Invalid path to markdown directory!") sys.exit(1) -if not DESTINATION_PATH_TO_PDF.exists(): - DESTINATION_PATH_TO_PDF.mkdir() - markdown_files = list(SOURCE_PATH_TO_MD.rglob("*.md")) if not markdown_files: print(f"No markdown files found in {SOURCE_PATH_TO_MD}") + sys.exit(1) + +if not DESTINATION_PATH_TO_PDF.exists(): + DESTINATION_PATH_TO_PDF.mkdir() source_md_files = [] output_pdf_files = [] -print("Convert MD to PDF:\n") +print("Converter from markdown to PDF\n") +print(f"Input directory: {SOURCE_PATH_TO_MD.absolute()}") +print(f"Output directory: {DESTINATION_PATH_TO_PDF.absolute()}\n") for markdown_file in markdown_files: relative_path = markdown_file.relative_to(SOURCE_PATH_TO_MD) pdf_output_path = DESTINATION_PATH_TO_PDF / relative_path.with_suffix(".pdf") @@ -40,12 +43,12 @@ try: pypandoc.convert_file( str(markdown_file), - 'pdf', + "pdf", outputfile=str(pdf_output_path), extra_args=[ - '--pdf-engine=pdflatex', - '--from=markdown+rebase_relative_paths' - ] + "--pdf-engine=pdflatex", + "--from=markdown+rebase_relative_paths", + ], ) except Exception as e: print(f"Error converting {markdown_file}: {e}") @@ -53,8 +56,8 @@ print("Source markdown files:") for input_md in source_md_files: - print(input_md) + print(input_md.absolute()) print("\nOutput PDF files:") for output_pdf in output_pdf_files: - print(output_pdf) + print(output_pdf.absolute()) diff --git a/images/converter-python/Dockerfile b/images/converter-python/Dockerfile new file mode 100644 index 0000000..c9f03eb --- /dev/null +++ b/images/converter-python/Dockerfile @@ -0,0 +1,21 @@ +ARG PANDOC_IMAGE_NAME=pandoc/latex +ARG PANDOC_IMAGE_TAG=edge-ubuntu + +FROM ${PANDOC_IMAGE_NAME}:${PANDOC_IMAGE_TAG} AS pypandoc + +RUN apt-get update && \ + apt-get install -y \ + unzip python3 python3.12-venv python3-pip -y && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +RUN pip3 install pypandoc pypandoc-binary \ + --break-system-packages + +RUN mkdir /app + +COPY converter.py /app/converter.py + +ENTRYPOINT ["python3", "/app/converter.py"] +CMD [] + diff --git a/images/pypandoc-python/Dockerfile b/images/pypandoc-python/Dockerfile new file mode 100644 index 0000000..43f785f --- /dev/null +++ b/images/pypandoc-python/Dockerfile @@ -0,0 +1,15 @@ +ARG PANDOC_IMAGE_NAME=pandoc/latex +ARG PANDOC_IMAGE_TAG=edge-ubuntu + +FROM ${PANDOC_IMAGE_NAME}:${PANDOC_IMAGE_TAG} AS pypandoc + +RUN apt-get update && \ + apt-get install -y \ + unzip python3 python3.12-venv python3-pip -y && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +RUN pip3 install pypandoc pypandoc-binary \ + --break-system-packages + +ENTRYPOINT ["python3"] diff --git a/images/pypandoc-python/entrypoint.sh b/images/pypandoc-python/entrypoint.sh new file mode 100644 index 0000000..d0bfc85 --- /dev/null +++ b/images/pypandoc-python/entrypoint.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +# shellcheck source=/dev/null +source /data/venv/bin/activate +exec "$@"