Skip to content

Commit

Permalink
build(docker): come on, make it do something!
Browse files Browse the repository at this point in the history
  • Loading branch information
TheManchineel committed Dec 11, 2024
1 parent 0e0d1fd commit 1c67e25
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 22 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ concurrency:

jobs:
# Build job
# TODO: fix permissions so we don't need to do everything as root
build:
if: '!contains(github.event.head_commit.message, ''skip ci'') && !contains(github.event.head_commit.message, ''build(docker)'')'
runs-on: ubuntu-latest
Expand Down Expand Up @@ -58,7 +59,7 @@ jobs:
shell: bash
working-directory: /workspace
run: |
sudo /root/build_docs.sh
sudo /root/build_docs_v2.py
- name: Create index.html
run: |
find . -type d -mindepth 1 -maxdepth 1 -print0 | sort -z | while read -d $'\0' dir
Expand Down
6 changes: 2 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
FROM pandoc/core:3.5
ENV CHROME_BIN="/usr/bin/chromium-browser" \
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD="true"
USER root
COPY build_docs.sh /root/build_docs.sh
RUN apk add --update udev sudo bash git python3 ttf-freefont chromium npm && npm install -g [email protected] --unsafe-perm=true && chmod +x /root/build_docs.sh
COPY build_docs_v2.py /root/build_docs_v2.py
RUN apk add --update sudo bash git python3 ttf-freefont && chmod +x /root/build_docs_v2.py
WORKDIR /
ENTRYPOINT ["/bin/bash"]
17 changes: 0 additions & 17 deletions build_docs.sh

This file was deleted.

35 changes: 35 additions & 0 deletions build_docs_v2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/python3
import datetime
import pathlib
from subprocess import Popen

# find files with .md extension min depth 2
for path in pathlib.Path("/workspace").rglob("*/*.md"):
print(f"Processing {path}...")
# get the file's last modified time
last_modified = datetime.datetime.fromtimestamp(path.stat().st_mtime).strftime("%Y-%m-%d %H:%M:%S")
output_filename = path.parent / f"{path.stem}.html"
Popen(
[
"pandoc",
"--template",
"template.html",
"--toc",
"--katex=https://cdn.jsdelivr.net/npm/[email protected]/dist/",
"--metadata",
"toc-title=Indice",
"--metadata",
"lang=it",
"--metadata",
f"date={last_modified}",
"--metadata",
"maxwidth=100vw",
"--verbose",
"-o",
output_filename,
path,
]
).wait()

print("Done! :)")
# TODO: move index build process here

0 comments on commit 1c67e25

Please sign in to comment.