Skip to content

Cryogen Blog template with staging and Practicalli theme #1

@practicalli-johnny

Description

@practicalli-johnny

Create a Cryogen template to create a new blog project that includes

  • publishing pull requests to a staging blog
    • modified src.cryogen.core/-main to take a config file via the command line
    • GitHub workflow to publish to a separate staging repository
  • include practicalli theme
  • option to select the default theme ??

Cryogen includes a deps-new template that simply copies from the Leiningen template

Code modifications

Allow a configuration file to be passed to the -main function, which is used to build and publish the Cryogen blog

TODO: refactor the code so that the zero argument branch calls the config-file branch, e.g.

(defn -main
  "Start Cryogen with optional configuration file"
  ([]
   (-main "content/config.edn") ;; TODO: test this approach works and path to config file is correct
   ;; (load-plugins)
   ;; (compile-assets-timed )
   ;; (System/exit 0))
  ([config-file]
   (load-plugins)

   ;; Would edn reader be better than read-string?
   (compile-assets-timed (read-string (slurp config-file)))
   (System/exit 0)))

Publish Staging Website GitHub workflow

---
name: Publish Blog Staging

on: [pull_request]
jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Prepare java
        uses: actions/setup-java@v3.5.1
        with:
          distribution: 'temurin'
          java-version: '17'

      - name: 'Cache Clojure Dependencies'
        uses: actions/cache@v3
        with:
          path: |
            ~/.m2/repository
            ~/.gitlibs
          key: cache-clojure-deps-${{ hashFiles('**/deps.edn') }}
          restore-keys: cache-clojure-deps-

      - name: Install clojure tools
        uses: DeLaGuardo/setup-clojure@9.5
        with:
          cli: 1.11.1.1165

      - name: Build Blog site
        run: clojure -M:build content/config-staging.edn

      - name: Publish to GitHub Pages
        # Publish to a separate repository as GitHub pages can only be served from one branch
        # The GitHub repository for staging the website must be created before running this workflow
        # Requires developer token as deploying across repositories
        uses: JamesIves/github-pages-deploy-action@v4.4.1
        with:
          repository-name: practicalli/blog-staging
          token: ${{ secrets.CRYOGEN_PUBLISH_TOKEN }}
          branch: gh-pages # The branch the action should deploy to.
          folder: public/blog-staging # The folder the action should deploy.
          commit-message: ${{ github.event.head_commit.message }}
          single-commit: yes

Related: practicalli/clojure#404

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions