gitlab-cihakyll

gitlab-ci.yml file template for hakyll website project


Is there a hakyll template for GitLab gitlab-ci.yml?

I found there are some on gitlab

  1. https://gitlab.com/jtojnar/hakyll
  2. https://gitlab.com/pages/hakyll

I use the following file in the choice 2

image: haskell:latest

before_script:
  - apt-get update && apt-get install xz-utils make
  - export STACK_ROOT=`pwd`/.stack
  - stack setup
  - stack install --only-dependencies
  - stack build

build:
  cache:
    paths:
      - _cache
      - .stack
  script:
    - stack exec site build
  rules:
    - if: $CI_COMMIT_REF_NAME != $CI_DEFAULT_BRANCH

pages:
  cache:
    paths:
      - _cache
      - .stack
  script:
    - stack exec site build
  artifacts:
    paths:
      - public
  rules:
    - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH

My pipeline gets an error on

$ stack install --only-dependencies
Error parsing targets: The specified targets matched no packages.
Perhaps you need to run 'stack init'?
Cleaning up project directory and file based variables 00:01
ERROR: Job failed: exit code 1

Does anyone know what should I do to make the pipeline work?


Solution

  • I finally figure it out and hope it can help someone.

    as the error said, I need to add stack init, I added stack init after stack setup

    Another thing need to notice that I have to copy the generated site folder into the public folder. In the hakyll, it will gerenate a folder called _site, this is the folder I need to mv _site public. Be care with the directory. gitlab-ci.yml with start with you project directory and the public folder will in the project directory, not it sub-directory. Make sure you move the _site folder into public.