HUGO

Deployment with Gitlab and rsync

Here is my deployment with gitlab-ci and rsnc

  1. Login via ssh on the remote server
  2. ssh-keygen -t rsa -b 4096
  3. cd .ssh
  4. cp id_rsa_id.pub authorized.keys
  5. copy the content from id_rsa as PRIVATE_HOST_KEY
  6. ssh-keyscan example.com
  7. copy the content from ssh-keyscan as PRIVATE_HOST_KEY

.gitlab-ci.yml

# All available Hugo versions are listed here: https://gitlab.com/pages/hugo/container_registry
# image: registry.gitlab.com/pages/hugo:latest
image: monachus/hugo:latest


before_script:
  - apt-get update
  - apt-get --yes --force-yes install git ssh rsync
  - git submodule update --init --recursive

pages:
  script:
    - hugo
    - mkdir "${HOME}/.ssh"
    - echo "${SSH_HOST_KEY}" > "${HOME}/.ssh/known_hosts"
    - echo "${SSH_PRIVATE_KEY}" > "${HOME}/.ssh/id_rsa"
    - chmod 700 "${HOME}/.ssh/id_rsa"
    - rsync -hrvz --delete --exclude=_ public/ user@example.com:www/test/


  artifacts:
    paths:
    - public
  only:
  - master

test:
  script:
  - hugo
  except:
  - master
3 Likes