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:

  1. 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.

  2. Invite a new robot user with a valid email address (for example, deploy@yourdomain.com) to the Robots role.

  3. 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.

  4. 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"

  5. 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:

  1. Environment variable: APTIBLE_APP, the name of the App to deploy.
  2. Environment variable: APTIBLE_ENVIRONMENT, the name of the Aptible environment in which your App lives.
  3. Secret: APTIBLE_USERNAME, the username of the Aptible user with which to deploy the App.
  4. 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:

on:
  push:
    branches: [ main ]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Deploy to Aptible
        uses: aptible/aptible-deploy-action@v4
        with:
          type: git
          app: ${{ vars.APTIBLE_APP }}
          environment: ${{ vars.APTIBLE_ENVIRONMENT }}
          username: ${{ secrets.APTIBLE_USERNAME }}
          password: ${{ secrets.APTIBLE_PASSWORD }}

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:

  1. 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.

  2. Invite a new robot user with a valid email address (for example, deploy@yourdomain.com) to the Robots role.

  3. 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:

on:
  push:
      branches: [ main ]

env:
  IMAGE_NAME: user/app:latest
  APTIBLE_ENVIRONMENT: "my_environment"
  APTIBLE_APP: "my_app"


jobs:
  deploy:
    runs-on: ubuntu-latest

      # Allow multi platform builds.
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v2

      # Allow use of secrets and other advanced docker features.
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v2

      # Log into Docker Hub
      - name: Login to DockerHub
        uses: docker/login-action@v2
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}

      # Build image using default dockerfile.
      - name: Build and push
        uses: docker/build-push-action@v3
        with:
          push: true
          tags: ${{ env.IMAGE_NAME }}

      - name: Deploy to Aptible
        uses: aptible/aptible-deploy-action@v4
        with:
          username: ${{ secrets.APTIBLE_USERNAME }}
          password: ${{ secrets.APTIBLE_PASSWORD }}
          environment: ${{ env.APTIBLE_ENVIRONMENT }}
          app: ${{ env.APTIBLE_APP }}
          docker_img: ${{ env.IMAGE_NAME }}
          private_registry_username: ${{ secrets.DOCKERHUB_USERNAME }}
          private_registry_password: ${{ secrets.DOCKERHUB_TOKEN }}

From there, you can review our resources for Direct Docker Image Deployments!