Generating the static pages and then upload them to the remote machine takes a lot of effort beside writing a post. And the job is so repetitive. So, CI is a very good use case for this. But, as I use private repo for this, most of the prominent CI hosts charge a lot to build for private repos. After searching a little bit, got the name of Vexor. The best thing is that, they are not limiting you, 1 build unit, 2 build units, private repo etc. You start with free 100 build minutes, then $0.015/min. Quite cheap. And no prior commitment with huge monthly subscriptions (Others are really pricey. I don’t understand, why do they charge over $30/month for a single unit, while builds for most of the normal projects does not go over 1hr. And how many builds per day a project can see. I don’t know.) So, I pleased with the pricing matrix of Vexor.
Update Probably Vexor recently has updated their pricing policy. At least they sent mails to it’s users that, there would be no free build minutes. Builds will be invoiced at a rate of $0.015/min, but there is no change in the pricing plans on their website. Please check with the support before creating an account.
One problem with them is they have not yet completed their documentation fully. And their whole doc is full of examples of building Ruby applications. Probably they are fond of Ruby. I’ve no complains. But they should include at-least some full examples for NodeJS. Then I came across one of the features in their build system. You can log into the build container for 30 mins (if you enable ssh) to debug. So, nice feature. Probably use only once for one project but that’s big.
So, I started to configure. First steps are quite straight-forward. Go to Vexor. Sign up with Github or GitLab or Bitbucket account. Enable your repo. You should be able to see the repo in your Dashboard. As soon as the repo is connected, it will try to start the build. But, my repo was not configured. Naturally, first build failed. Then I started to configure.
First, added one file to the root of the repo by the name
vexor.yml, without the leading dot is also permissible).
As I want to build for NodeJS. I added
language: node_js. They have support for several versions of Node. I added for
language: node_js node_js: - "6.1.0"
I use Hexo to generate the site. And this needs
hexo-cli to be installed globally. So, I added
npm install -g hexo-cli and of-course
npm install to the
install: - npm install -g hexo-cli - npm install
As I’ve included one post-install hook to the
package.json with the command
hexo generate, practically I’ve nothing to do for generation of static content in the
Now, I need to upload the generated content to the remote site. So, added some lines (with the help of Domenic) to the
before_script section to add the
before_script: - chmod 600 /home/vexor/.ssh/id_rsa - eval `ssh-agent -s` - ssh-add /home/vexor/.ssh/id_rsa
The available key in the
.ssh is the private key you have to add in the settings of the project. You can generate one key pair by
ssh-keygen -t rsa -b 4096 -C "email@example.com". More detail. And add the content of the public key of the pair to a file named
authorized_keys in the
.ssh directory of
home of the user, you want to deploy with, to the remote machine.
To deploy I’ve added one shell script file, named
deploy in my repo. (taken from here). Only I modified the
server address, added
cd public (from where we need to upload), the remote directory path and removed the
deploy need to executable. So, added
chmod +x ./deploy to the
And finally in the
script section added
./deploy live go, which will deploy the generated content to the remote directory, if all things go successfully.
If anyone needs the full glimpse of
.vexor.yml, here it is,
language: node_js node_js: - "6.1.0" install: - npm install -g hexo-cli - npm install before_script: - chmod 600 /home/vexor/.ssh/id_rsa - eval `ssh-agent -s` - ssh-add /home/vexor/.ssh/id_rsa - chmod +x ./deploy script: ./deploy live go