Dit product is onderdeel van Infowijs - een studio met maarschappelijk hart.
  • Module deployment

Deploy using CircleCI

The preferred way of deploying your modules to Includable is through the Includable CLI, but doing that manually can be tedious and error-prone.

This can be automated however through the continious integration platform like CircleCI.

Creating a CircleCI config file

Every CI solution has their own way of configuring what scripts and tests to run. CircleCI requires you to add a file called .circleci/config.yml to your repo. Let’s add that with the following contents:

version: 2
jobs:
  build:
    working_directory: ~/app
    docker:
      - image: includable/cli
    steps:
      - checkout
      - deploy:
          name: Deploy to Includable
          command: |
            if [ "${CIRCLE_BRANCH}" == "master" ]; then
              inc publish
            else
              echo "Not on master branch, so not deploying."
            fi

This file will use the Docker image includable/cli to run the inc publish command within your repository.

It will only run if the Git branch name is equal to master, so that features that are still in development in other branches won't be deployed. You can of course change master to any other branch name if you wish to deploy from a different branch in your repository.

Make sure to push the commit with the added file to Github before continuing.

Activate CircleCI

Sign in to CircleCI with your Github account. Click the 'Add projects' option in the menu on the left, and find your project.

Click the blue 'Set up project' button next to your repository name, and click 'Start build' on the next screen.

Add your token

The first build will probably fail, because the inc command isn't able to publish your module yet since it is not signed in. To fix that, we will add your Includable account token to CircleCI.

You can get your token by going back to your command line, and running inc login --token. The value you will then get back you can add to your environment variables in the CircleCI settings:

CircleCI Environment Variables

Done!

That should do it, you have now set up a continuous integration flow to automatically build and publish any changes you push to your Github repository automatically to Includable.

Example code

You can find the example code for this guide on Github: example-circleci.