logoalt Hacker News

vbezhenartoday at 8:31 AM5 repliesview on HN

I wonder what would be a good way to generate a website with minimal software installations, for example in standard github runner image. This example uses comrak tool to process markdown into HTML.

I've come up with using Java and XSLT. Java is installed in Github Runner image and there's built-in XSLT support in Java standard library. You can write HTML and use XSLT to add header, footer and do other processings if necessary.

So basically I want to generate a website in github runner without accessing network to install something else.

I guess one could just `cat header.html content.html footer.html` but that requires a lot of tiny things like extracting title from content and inserting it into header, etc. Nothing that lots of greps and seds couldn't handle, of course...


Replies

captn3m0today at 11:04 AM

For minimal stuff, I just have a pre-commit hook that runs

    pandoc -s README.md -o index.html
I've done the xlst thing as well, but to generate markdown instead of HTML from Zotero export XML as the input. https://github.com/captn3m0/boardgame-research. But again, I throw the make command into a pre-commit because I want the README to be updated in the same commit.
weitendorftoday at 9:45 AM

We do basically this for our tests in statue: https://github.com/accretional/statue/tree/main/test/hermeti...

npm pack builds the file locally, then we expose it to the container filesystem where we do a build and check the outputs. You can move dependencies to bundledDependencies in npm to embed them in the image.

However, this is assuming you're rebuilding the static site generator itself every time. If you just want to build a site using an existing static site generator, it's much easier provided that the site generator itself is easy to use (for example, ours has a one-liner to take you all the way from nothing to a local static site running on localhost, see https://statue.dev)

If you aren't changing the SSG code itself between container runs you'd just mount the markdown to the container and pre-install the ssg in the Dockerfile itself. For statue.dev that would just be a Dockerfile almost exactly the same as the one we use already, except you'd use your own script, and RUN this in the Dockerfile itself: yes | npx sv create . --template minimal --types ts --no-add-ons --install npm && npm install statue-ssg && npx statue init && npm install

In your script you'd just npm run build then do whatever it is you want to do to send the files somewhere, and wherever starts the script, you'd do something like -v "pathtomymarkdown/foo:/test-package/" - not sure how to do this in github runners.

Depending on how interested you/other people are in doing this with statue.dev, we could prob get something like this (where the markdown is parameterized, not the npm package) working by Tuesday. We're building out the sandbox/build features on our cloud platform as we speak, this could be one of the first use cases/defaults.

adityaathalyetoday at 10:26 AM

In fact, that is my line of thinking, except "using whatever already exists on my computer(s)", which is: bash, sed, grep, jq, awk, pandoc, inotifywait, and xdotool.

The point being exactly to avoid whatever a third party may or may not deign to let me use, without hassle.

qznctoday at 8:44 AM

For GitHub just use Jekyll provided by GitHub itself?

lionkortoday at 8:38 AM

A good way to do that with anything, I found, is a Makefile which downloads and compiles the few things it needs :D

show 1 reply