Susi Skill CMS is a web application framework to edit susi skills. It is currently in development stage, hosted on http://skills.susi.ai. It is built using ReactJS . In this blogpost we will see how to automatically deploy the repository on gh pages.
Setting up the project
Fork susi_skill_cms repository and clone it to your desktop, make sure you have node and npm versions greater than 6 and 3 respectively. Next go to cloned folder and install all the dependencies by running :
Next run on http://localhost:3000 by running the command
To auto deploy changes on gh-pages branch, we need to setup Travis for the project. Register yourself on https://travis-ci.org/ and turn on the Travis for this repository. Next add .travis.yml in the root directory of the source folder.
The travis configuration files will ensure that the project is building for every changes made, using npm run test command, in our case it will only consider changes made on master branch , if you want to watch other branches to add the respective branch name in travis configurations. After checking for build passing we need to automatically push the changes made for which we will use a bash script.
Source : Bash script for automatic deployment
This bash script will enable travis ci user to push changes to gh pages, for this we need to store the credentials of the repository in encrypted form. To get the public/ private rsa keys use the following command
It will generate keys in .ssh/id_rsa folder in your home repository.
Make sure you do not enter any passphrase while generating credentials otherwise travis will get stuck at time of decrypting the keys. Copy the public key and deploy the key to repository by visiting https://github.com/<your name>/<your repo>/settings/keys
Next install travis for encryption of keys.
Encrypt your private deploy_key and add it to root of your repository using command
After successful encryption, you will see a message
Add the above generated script in travis and push the changes on your master branch. Do not push the deploy_key only the encryption file deploy_key.enc
Finally, add the deploy link of gh pages in package.json of your using key “homepage”.
And in scripts of package.json add
Commit and push your changes and from now onward all your changes will be automatically pushed to gh pages branch. For contribution visit Susi_Skill_CMS.
- A blog on deploying a React app by Jake Weisler https://medium.freecodecamp.org/surge-vs-github-pages-deploying-a-create-react-app-project-c0ecbf317089
- A github gist on deploying app by Domenic Denicola https://gist.github.com/domenic/ec8b0fc8ab45f39403dd#get-encrypted-credentials
- Github help pages for adding ssh agent https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/