Testing Hugo Themes With Gitlab CI/CD

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

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.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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.