How to deploy a static website to Github Pages using CircleCI

Posted on Sun 24 February 2019 in Web • Tagged with ci, circleci, github, static, website, deploy

Since I created my blog with a static pages generator, I've been using TravisCI to automate the pages build and deployment. My desire to learn something new (we are using CircleCI at work, but I never configured it from scratch) and the recent news about TravisCI acquisition and employees layoff, led me to think about moving to a different service.

Github Pages

Every account on Github can use a special repository to publish static pages. In my case, since I have github.com/andreagrandi, my special repository is named github.com/andreagrandi.github.io. Once I publish my pages there, they will be accessible from https://andreagrandi.github.io.

You will need to use the master branch of the special repository directly and not the gh-pages branch which is available to each repository.

CircleCI

CircleCI is a very flexible and powerful continuous integration tool, which is also free for open source projects. As long as your static website is located on a public repository on Github, you won't have to pay anything to use it. In my case, the surce code of this website is available at https://github.com/andreagrandi/andreagrandi.it

Configuration

You can find the complete configuration at this address. The only value you won't find is GH_TOKEN. You need to generate this token on Github, at this address: https://github.com/settings/tokens. Give it a nice description like "CircleCI deployment token", select repo scope and finally click Generate token button. This token will be used to git push... your pages once they are built. Please remember to keep this token secret and not to publish it anywhere.

In my configuration you may notice that I'm using Pelican static websites generator, but apart from a few changes, the structure of the configuration should be very similar even if you use Jekill, Hugo etc... it doesn't really matter how you generate the pages, the deployment phase will be the same.

Deployment script

You will notice that there is a complete bash script embedded in the CircleCI configuration. This script configures git, fetches the existing andreagrandi.github.io repository, and sync the built pages with the existing ones (this avoid creating a commit which contains all the pages so it will contain just the added content). Once the commit is made, the script will finally push the changes to the repository.

Please note: regardless of CircleCI settings, the deployment will only happens if we are pushing (or merging a pull request) to master (if [ "${CIRCLE_BRANCH}" = "master" ]; then) and it will actually commit and push pages only if there is something new to commit (if git commit -m "CircleCI build $CIRCLE_BUILD_NUM pushed to Github Pages" ; then). For example if I'm just updating something in the CircleCI configuration, which doesn't change anything in the content, the pages won't be deployed again.

Conclusion

My first impression of CircleCI is that is faster than TravisCI and this means that I can publish my content more quickly. The possibility of using Docker containers as base image is really powerful and in more complex scenarios we can reproduce the building environment locally on our machine. If you have any advices about how to improve my build script, feel free to leave a comment here.


Using QtCreator to deploy and run a Qt application to a remote Linux device

Posted on Thu 17 January 2013 in HowTo • Tagged with deploy, Linux, Qt, QtCreator, SDK, Ubuntu

QtCreator is a very flexible IDE and can really be adapted for a lot of things. I usually use it to develop mobile applications for Nokia N9 and BlackBerry 10, but it can be used for more generic tasks. In my case I wanted to be able to develop a Qt application using my desktop PC, deploy it and run on a remote (actually it's on the same desk) Linux machine running Xubuntu.

Doing this is quite easy and you don't need any specific plugin on QtCreator, but be sure to have at least version 2.6.x. Other than QtCreator you also need two Linux based PC (I used Ubuntu 12.10 for my development machine and Xubuntu 12.10 for the remote netbook) and an SSH account on the remote PC.

Add the remote device to QtCreator

QtCreatorDevice

To add the remote Linux device on QtCreator, use the Tools->Options menu and click on "Devices" item. At this point click on "Add" button and fill the fields using values similar to the screenshot. In particular specify a name for the device, the IP of the remote machine and a username and password that must already exist (I just created the user "andrea" on the Xubuntu machine and used the same password). I also had to set the timeout to 20 seconds, because I had some connection problems and the connection kept dropping after 10 seconds trying. To verify if everything is working fine, just click on Test button.

Add a specific Qt version

QtCreatorQtVersion

To write your application you may need a specific Qt version that is different from the one distributed by your Linux distribution. There's no problem, QtCreator let you add different Qt versions without any conflict. In my case I installed the Qt5 version distributed by Canonical Qt5 Edgers Teamhttps://launchpad.net/~canonical-qt5-edgers
Once it's installed, just click on "Add" button and select the qmake specific to the version you want to add (in my case it was in /opt/qt5/bin/qmake ).

Add a Qt Kit

QtCreatorQtKits

QtCreator permits to add new Kit (development configurations) and these kits are used during project creation to specify what you want to target. In my example I added a new kit choosing an appropriate name "Qt5 Ubuntu", the device type, the actual device previously configured and finally the Qt version that we added before. With a kit I have a complete "toolchain" that allow me to write applications for a particular device, with a specific Qt version.

Putting the pieces together

At this point you just have to create a new "Qt Quick 2" application, and select the new kit you just created instead of the "Desktop" one. Please note that there is a little problem that I haven't fixed yet (but I'm working on it): if you create, for example, a project named "QtTest1" it will be deployed to the folder /opt/QtTest1/ on the remote machine. By default your user doesn't have read+write permissions for that folder so I manualy created the folder and I gave a chmod 777 on it, just for testing. There are two possible ways to fix this: you could create a specific user that has read+write permissions on /opt/ or you could modify the deployment configuration to have the app deployed to the user /home (I will investigate on this possibility and I will write something in one of the next posts).

Final thoughts

What all of this could be useful for? Well, do 2+2 and you'll easily guess ;) In the next weeks I will post more specific informations and I will update everyone with my progresses. Any comment is welcome! If you want to contribute to this you're welcome too of course.