Go Back

Testing Hugo Themes With Gitlab CI/CD

Published on: September 4, 2020 | Reading Time: 2 min

gitlab
ci
cd

I use Gitlab. This blog is built with and deployed using Gitlab. I like Gitlab. The community edition is Free Software. It really cover the whole development life cycle. Github is catching up but it still has a lot of proprietary bits. I also help package and maintain Gitlab in the Debian archives.

So Gitlab by default looks into a little file called .gitlab-ci.yml for CI/CD instructions. So let's start slow and test for Debian Stable which is what I use on a daily basis.

stages:
  - build
  - test
  - pages

debian-test:
  stage: build
  image: "debian:stable"
  before_script:
    - apt-get update -y
    - apt-get install -y git hugo neofetch
  script:
    - neofetch
    - hugo new site test && cd test
    - mkdir themes/gruvhugo
    - cp -r ../archetypes themes/gruvhugo
    - cp -r ../exampleSite themes/gruvhugo
    - cp -r ../layouts themes/gruvhugo
    - cp ../LICENSE themes/gruvhugo
    - cp ../README.md themes/gruvhugo
    - cp -r ../static themes/gruvhugo
    - cp ../theme.toml themes/gruvhugo
    - rm -rf ../content && cp -r themes/gruvhugo/exampleSite/content/ .
    - rm config.toml && cp themes/gruvhugo/exampleSite/deploy.toml ./config.toml
    - mkdir static/img && cp themes/gruvhugo/static/img/logo.png static/img/
    - hugo
    - echo "Build on Debian Stable successfull!"

test:
  stage: test
  image: registry.gitlab.com/pages/hugo:latest
  script:
    - hugo
    - echo "Test Successfull for Hugo Latest"
  except:
    - master

pages:
  stage: pages
  image: registry.gitlab.com/pages/hugo:latest
  script:
    - hugo new site test && cd test
    - mkdir themes/gruvhugo
    - cp -r ../archetypes themes/gruvhugo
    - cp -r ../exampleSite themes/gruvhugo
    - cp -r ../layouts themes/gruvhugo
    - cp ../LICENSE themes/gruvhugo
    - cp ../README.md themes/gruvhugo
    - cp -r ../static themes/gruvhugo
    - cp ../theme.toml themes/gruvhugo
    - rm -rf ../content && cp -r themes/gruvhugo/exampleSite/content/ .
    - rm config.toml && cp themes/gruvhugo/exampleSite/deploy.toml ./config.toml
    - mkdir static/img && cp themes/gruvhugo/static/img/logo.png static/img
    - hugo
    - mv public ../
  artifacts:
    paths:
      - public
  only:
    - master

This is still a working progress and this page will be updated as I make the pipeline better.