This article explains how to deploy sites to GitLab Pages using GitLab CI.
Workflow§
Create .gitlab-ci.yml
at the root of your site with the following contents:
1image: registry.gitlab.com/pages/hugo/hugo_extended:latest
2
3variables:
4 HUGO_ENV: production
5
6default:
7 before_script:
8 - apk add --update --no-cache git go npm
9 - npm install
10
11test:
12 script:
13 - hugo --gc --minify
14 rules:
15 - if: $CI_COMMIT_REF_NAME != $CI_DEFAULT_BRANCH
16
17pages:
18 script:
19 - hugo --gc --minify
20 artifacts:
21 paths:
22 - public
23 rules:
24 - if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
The example above will only deploy the default branch to GitLab Pages and run a test on the rest of the branches.
See also:
Comments