I have been playing around with a private Gitlab server. My goal was to automatically build and deploy my hugo site for my private web server. After looking around in the internet for similar solutions, I came up with the following solution for .gitlab-ci.yml
stages:
- build
- deploy
build:
stage: build
image: registry.gitlab.com/pages/hugo/hugo_extended:latest
script:
- hugo
artifacts:
paths:
- public
only:
- master
# deploy with ftp following instructions from https://www.savjee.be/2019/04/gitlab-ci-deploy-to-ftp-with-lftp/
deploy:
stage: deploy
image: alpine
before_script:
- apk update
- apk add lftp
script:
# Sync to FTP
- lftp -c "set ftp:ssl-allow no; open ftp.ssl-login.nl; user $FTP_USERNAME $FTP_PASSWORD; mirror -X .* -X .*/ --reverse --verbose --delete public/ public_html/"
I use gitlab’s hugo_extended
image because I use SASS for my stylesheet and this needs to be converted automatically. I then use an alpine
image and add lftp
to be able to upload the converted files to my web server.