Aptible PaaS logoDocs

How to integrate Aptible with CI Platforms

At a high level, integrating Aptible with your CI platform boils down to the following steps:

  • Create a robot User in Aptible for your CI platform.
  • Trigger a deploy to Aptible whenever your CI process completes. How you do this depends on how you're deploying to Aptible:

Creating a Robot User

  1. Create a "Robots" role in your Aptible organization, and grant it "Read" and "Manage" permissions for the environment you'd like to automate deployment to.
  2. Invite a new user to this Robots role. This user needs to have an actual email address. You can use something like deploy@yourdomain.com.
  3. Log out of your Aptible account, accept the invitation you received for the robot user by email, and create a password for the robot user.

Suppose you use this user to deploy an app using Dockerfile Deploy. In that case, you're also going to need an SSH keypair for the robot user to let them connect to your app's Git Remote:

  1. Generate an SSH key pair for the robot user using ssh-keygen -f deploy.pem. Don't set a password for the key.
  2. Register the SSH Public Key with Aptible for the robot user.

Triggering a Deploy

Dockerfile Deploy

Most CI platforms expose a form of "after-success" hook you can use to trigger a deploy to Aptible after your tests have passed. You'll need to use it to trigger a deploy to Aptible by running git push. For the git push to work, you'll also need to provide your CI platform with the SSH key you created for your robot user. To that end, most CI platforms let you provide encrypted files to store in your repository.

Direct Docker Image Deploy

To deploy with Direct Docker Image Deploy:

  1. Build and publish a Docker Image when your build succeeds.
  2. Install the Aptible CLI in your CI environment.
  3. Log in as the robot user, and use aptible deploy to trigger a deploy to Aptible.

Keep reading