So beulogue is hosted on Gitlab. My blog (private repo) is also there.
Since beulogue is a static site generator, I have to upload my files myself. Kinda boring. Let's try Gitlab pipelines !
First, we need to configure some secret variables:
REMOTE_DOMAIN
with the domain to push the filesREMOTE_PATH
with the target folderREMOTE_USER
with the name of the remote userSSH_HOST_KEY
with the result ofssh-keyscan your-domain.something
(the line starting withyour-domain.something ssh-rsa
)SSH_PRIVATE_KEY
with the content of the private key created for the CI
Then, I need to add my public key to the server authorized keys (~/.ssh/authorized_keys
relative to the REMOTE_USER
home directory).
Here is my .gitlab-ci.yml
file:
image: node:6
build:
before_script:
- apt-get update -y
- apt-get -y install rsync
- echo "${SSH_PRIVATE_KEY}" > id_rsa
- chmod 700 id_rsa
- mkdir "${HOME}/.ssh"
- echo "${SSH_HOST_KEY}" > "${HOME}/.ssh/known_hosts"
- npm install -g beulogue
script:
- ./build.sh
- rsync -r -e 'ssh -i id_rsa' ./output/ ${REMOTE_USER}@${REMOTE_DOMAIN}:${REMOTE_PATH}
Then, each time I push a new article to Gitlab, the pipeline will build the blog and upload it to my server !
Thanks a lot to this article for everything.