CI/CD for hexo
Created at 2023-01-19 Updated at 2024-11-07 - 1 min. read
Currently, I tried to create a ci/cd pipeline for my blog. Since I don’t wanted it to be on my local system. As mostly, I end up burning my hard disk or formatting the system. Where I lose all my data and settings. The blog code is on gitlab. So below are the steps
Add runner (since I don’t want to use public runner)
Lint check for the code
Install node_modules
Push the files to github pages
For pushing code on github pages. You need majorly two environment variable
SSH_CONFIG
SSH_PRIVATE_KEY
In ssh_config below are the content
Host github.com
StrictHostKeyChecking no
Both the variable should have type as file.
Below is the sample .gitlab-ci.yaml file:
before_script:
- 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- chmod 400 "$SSH_PRIVATE_KEY"
- ssh-add “$SSH_PRIVATE_KEY”
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- cp "$SSH_CONFIG" ~/.ssh/config
- chmod 644 ~/.ssh/config