lots of things to make github action maybe work

This commit is contained in:
Pagwin 2024-12-30 18:30:06 -05:00
parent 4fc623a6a7
commit c7043b5fc3
No known key found for this signature in database
GPG key ID: 81137023740CA260
7 changed files with 46 additions and 12 deletions

2
.dockerignore Normal file
View file

@ -0,0 +1,2 @@
dist-newstyle
.shake

17
Dockerfile Normal file
View file

@ -0,0 +1,17 @@
FROM haskell
RUN mkdir -p /github/workspace
RUN cabal update
COPY ./psb.cabal /mnt
WORKDIR /mnt
RUN cabal build --only-dependencies
COPY . /mnt
RUN cabal build
WORKDIR /github/workspace
ENTRYPOINT ["/mnt/dist-newstyle/build/x86_64-linux/ghc-9.4.8/psb-0.1.0.0/x/psb/build/psb/psb", "build", "-p2"]

6
TODO
View file

@ -2,10 +2,12 @@ github action for deploy to github pages
minify js and css when copying over instead of just copying minify js and css when copying over instead of just copying
add in sass preprocessing with the cli
make typst dependant on yaml? make typst dependant on yaml?
add rst support so I'm not dependant on typst not breaking
add a cli flag to send webmentions and track the ones sent/acked in some file, probably a simple csv with path and what got linked to (https://indieweb.org/Webmention) (https://indieweb.org/Webmention-developer)
make it so typst citation section has a header and/or is a div elem instead of a section element make it so typst citation section has a header and/or is a div elem instead of a section element
process source code blocks with tree sitter https://hackage.haskell.org/package/tree-sitter process source code blocks with tree sitter https://hackage.haskell.org/package/tree-sitter

6
action.yml Normal file
View file

@ -0,0 +1,6 @@
# https://docs.github.com/en/actions/sharing-automations/creating-actions/metadata-syntax-for-github-actions
name: 'psb'
description: 'Use PSB to build'
runs:
using: 'docker'
image: 'Dockerfile'

View file

@ -69,7 +69,8 @@ assets =
map (outputDir </>) assetGlobs |%> \target -> do map (outputDir </>) assetGlobs |%> \target -> do
let src = FP.dropDirectory1 target let src = FP.dropDirectory1 target
Shake.copyFileChanged src target Shake.copyFileChanged src target
Shake.putInfo $ "Copied " <> target <> " from " <> src
-- Shake.putInfo $ "Copied " <> target <> " from " <> src
-- handling typst only because pages should only be typst no reason for backwards compat on that -- handling typst only because pages should only be typst no reason for backwards compat on that
pages :: Rules () pages :: Rules ()
@ -88,7 +89,8 @@ pages =
pageSection = T.pack $ fromJust $ Shake.stripExtension "html" target pageSection = T.pack $ fromJust $ Shake.stripExtension "html" target
} }
applyTemplateAndWrite "default.html" page target applyTemplateAndWrite "default.html" page target
Shake.putInfo $ "Built " <> target <> " from " <> src
-- Shake.putInfo $ "Built " <> target <> " from " <> src
-- there's probably a better way of doing this that allows for the target's origin file extension to get passed in but for now we're doing brute force -- there's probably a better way of doing this that allows for the target's origin file extension to get passed in but for now we're doing brute force
postsRule :: Rules () postsRule :: Rules ()
@ -127,7 +129,8 @@ typstPost src = do
pageSection = T.pack $ fromJust $ Shake.stripExtension "html" target pageSection = T.pack $ fromJust $ Shake.stripExtension "html" target
} }
applyTemplateAndWrite "default.html" page target applyTemplateAndWrite "default.html" page target
Shake.putInfo $ "Built " <> target <> " from " <> src
-- Shake.putInfo $ "Built " <> target <> " from " <> src
markdownPost :: FP.FilePath -> Action () markdownPost :: FP.FilePath -> Action ()
markdownPost src = do markdownPost src = do
@ -148,7 +151,8 @@ markdownPost src = do
pageSection = T.pack $ fromJust $ Shake.stripExtension "html" target pageSection = T.pack $ fromJust $ Shake.stripExtension "html" target
} }
applyTemplateAndWrite "default.html" page target applyTemplateAndWrite "default.html" page target
Shake.putInfo $ "Built " <> target <> " from " <> src
-- Shake.putInfo $ "Built " <> target <> " from " <> src
home :: Rules () home :: Rules ()
home = home =
@ -168,7 +172,8 @@ home =
pageSection = T.pack $ fromJust $ Shake.stripExtension "html" target pageSection = T.pack $ fromJust $ Shake.stripExtension "html" target
} }
applyTemplateAndWrite "default.html" page target applyTemplateAndWrite "default.html" page target
Shake.putInfo $ "Built " <> target
-- Shake.putInfo $ "Built " <> target
data Rss = Rss data Rss = Rss
{ now :: T.Text, { now :: T.Text,
@ -185,7 +190,7 @@ rss =
time <- Utilities.now time <- Utilities.now
applyTemplateAndWrite "feed.xml" (Rss time posts) target applyTemplateAndWrite "feed.xml" (Rss time posts) target
Shake.putInfo $ "Built " <> target -- Shake.putInfo $ "Built " <> target
readPost :: FilePath -> Action Post readPost :: FilePath -> Action Post
readPost postPath = do readPost postPath = do
@ -198,7 +203,7 @@ readTypstPost :: FilePath -> Action Post
readTypstPost postPath = do readTypstPost postPath = do
html <- typstToHtml postPath html <- typstToHtml postPath
post <- yamlToPost $ typstMetaPath postPath post <- yamlToPost $ typstMetaPath postPath
Shake.putInfo $ "Read " <> postPath -- Shake.putInfo $ "Read " <> postPath
return $ return $
post post
{ postContent = Just html, { postContent = Just html,
@ -208,7 +213,7 @@ readTypstPost postPath = do
readMarkdownPost :: FilePath -> Action Post readMarkdownPost :: FilePath -> Action Post
readMarkdownPost postPath = do readMarkdownPost postPath = do
(post, html) <- markdownToHtml postPath (post, html) <- markdownToHtml postPath
Shake.putInfo $ "Read " <> postPath -- Shake.putInfo $ "Read " <> postPath
return $ return $
post post
{ postContent = Just html, { postContent = Just html,

View file

@ -41,7 +41,7 @@ readTemplate templatePath = do
case eTemplate of case eTemplate of
Right template -> do Right template -> do
Shake.need . Mus.getPartials . Mus.ast $ template Shake.need . Mus.getPartials . Mus.ast $ template
Shake.putInfo $ "Read " <> templatePath --Shake.putInfo $ "Read " <> templatePath
return template return template
Left err -> fail $ show err Left err -> fail $ show err

View file

@ -68,10 +68,12 @@ executable psb
default-extensions: ApplicativeDo DataKinds NamedFieldPuns DerivingVia LambdaCase TypeApplications DeriveGeneric default-extensions: ApplicativeDo DataKinds NamedFieldPuns DerivingVia LambdaCase TypeApplications DeriveGeneric
-- Other library packages from which modules are imported. -- Other library packages from which modules are imported.
build-depends: base ^>=4.17.2.1, mustache ^>=2.4.2, pandoc ^>=3.2.1, shake ^>= 0.19.8, deriving-aeson ^>= 0.2.9, aeson, text, time, unordered-containers, yaml build-depends: base >=4.17.2.1, mustache >=2.4.2, pandoc >=3.2.1, shake >= 0.19.8, deriving-aeson >= 0.2.9, aeson, text, time, unordered-containers, yaml
-- Directories containing source files. -- Directories containing source files.
hs-source-dirs: app hs-source-dirs: app
-- Base language which the package is written in. -- Base language which the package is written in.
default-language: Haskell2010 default-language: Haskell2010
ghc-options: -threaded