How to deploy to Aptible with CI/CD
Overview
To make it easier to deploy on Aptible—whether you’re migrating from another platform or deploying your first application—we offer integrations with several continuous integration services.
If your team is already using a Git-based deployment workflow, deploying your app to Aptible should be relatively straightforward.
Deploying with Git
Prerequisites
To deploy to Aptible via Git, you must have a public SSH key associated with your account. We recommend creating a robot user to manage your deployment:
-
Create a
Robots
custom Aptible role in your Aptible organization. Grant it “Read” and “Manage” permissions for the environment where you would like to deploy. -
Invite a new robot user with a valid email address (for example,
deploy@yourdomain.com
) to theRobots
role. -
Sign out of your Aptible account, accept the invitation from the robot user’s email address, and set a password for the robot’s Aptible account.
-
Generate a new SSH key pair to be used by the robot user, and don’t set a password:
ssh-keygen -t ed25519 -C "your_email@example.com"
-
Register the SSH Public Key with Aptible for the robot user.
Configuring the Environment
First, you’ll need to configure a few environment variables and secrets for your repository:
- Environment variable:
APTIBLE_APP
, the name of the App to deploy. - Environment variable:
APTIBLE_ENVIRONMENT
, the name of the Aptible environment in which your App lives. - Secret:
APTIBLE_USERNAME
, the username of the Aptible user with which to deploy the App. - Secret:
APTIBLE_PASSWORD
, the password of the Aptible user with which to deploy the App.
Configuring the Workflow
Finally, you must configure the workflow to deploy your application to Aptible:
Deploying with Docker
Prerequisites
To deploy to Aptible with a Docker image via a CI integration, you should create a robot user to manage your deployment:
-
Create a
Robots
custom Aptible role in your Aptible organization. Grant it “Read” and “Manage” permissions for the environment where you would like to deploy. -
Invite a new robot user with a valid email address (for example,
deploy@yourdomain.com
) to theRobots
role. -
Sign out of your Aptible account, accept the invitation from the robot user’s email address, and set a password for the robot’s Aptible account.
Some of the below instructions and more information can also be found on the Github Marketplace page for the Deploy to Aptible Action.
Configuring the Environment
To deploy to Aptible via GitHub Actions, you must first create encrypted secrets for your repository with Docker registry and Aptible credentials:
DOCKERHUB_USERNAME
and DOCKERHUB_TOKEN
The credentials for your private Docker registry (in this case, DockerHub).
APTIBLE_USERNAME
and APTIBLE_PASSWORD
The credentials for the robot account created to deploy to Aptible.
Configuring the Workflow
Additionally, you will need to set some environment variables within the GitHub Actions workflow:
IMAGE_NAME
The Docker image you wish to deploy from your Docker registry.
APTIBLE_ENVIRONMENT
The name of the Aptible environment acting as the target for this deployment.
APTIBLE_APP
The name of the app within the Aptible environment we are deploying with this workflow.
Configuring the Workflow
Finally, you must configure the workflow to deploy your application to Aptible:
From there, you can review our resources for Direct Docker Image Deployments!