Automatic deployment using Wercker

February 26, 2016

I moved my website from Wordpress to static build website last week. After I finished that blog I looked into some continues deployment solutions.

After some research I choose the following solution:


My website is now open source and you can view all code on Github. There was no reason not to make it public and I thought it would be nice to share the build code. You can now leave feedback as a github issue.


Wercker is a tool to automate your deployments. Wercker is free for 2 concurrent builds. I setup a new application and connected it to my github project.


You have to add a wercker.yml build configuration to your project so wercker knows what to do with it. Below my build configuration:

box: node
    - npm-install
    - npm-test

    - hgen/gulp:
        tasks: build

The build starts a node box and runs the steps npm install, npm test and gulp build.

Deployment target

Now we would like to deploy this build to Google Cloud Storage. To do this I added the following deploy steps to the wercker.yml:

      - michilu/gcs-website-deploy:
        project: $GOOGLE_PROJECT_ID
        token: $GOOGLE_REFRESH_TOKEN
        dir: build

The gcd-website-deploy step requires a .boto config file in the project root. The credentials can be left empty:

gs_oauth2_refresh_token =
default_project_id =

Now all we have to to is add a deployment target your wercker application. I choose to auto deploy every successful build of the master branch.

As you can see we use the GOOGLE_PROJECT_ID and GOOGLE_REFRESH_TOKEN variables in the deploy section to the build script. Add them as environment variables to the deploy target. You can find your refresh token in the .boto file generated by the gsutil tool when running gsutil config.

Push to deploy

Now push some commits to the master branch and your website build will start. If the build is successful it will be deployed to Google Cloud Storage.

It is ofcourse good practice to build stuff in a feature branch. When the feature branch is complete and tested merge and push it to master.

Google Cloud Storage

I used Amazon AWS services in the past but for this project I tried Google Cloud Storage. It was easy to setup and I really like the Google Cloud Platform console.

I am not going into to much detail on how to set up Google Cloud Storage with your domain. Maarten-Jan has an excellent blog about this.

Thanks for reading.