Minimal CI Pipeline Examples

Who this is for

Developers who want to integrate CloudAIPilot deployments into a CI/CD pipeline (GitHub Actions, GitLab CI, or similar).

What you will complete

See working minimal examples of CI pipeline configurations that trigger CloudAIPilot deployments and wait for completion.

Before you begin

  • A CloudAIPilot API token stored as a CI/CD secret.
  • The ID of the site or app you want to deploy (visible in the URL when viewing the site/app in the dashboard).

Pattern 1: Deploy on push to main (via git webhook — no API needed)

The simplest approach requires no CI pipeline code at all. Link your repository to the CloudAIPilot site or app with the deploy branch set to main. Every push to main triggers a deployment automatically.

See KB-13-03 for setup instructions.

Use the API-based patterns below only when you need additional control (deploy only after tests pass, wait for completion, gate on deploy success, etc.).


Pattern 2: GitHub Actions — deploy after tests pass

name: Deploy to CloudAIPilot

on:
  push:
    branches: [main]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Run tests
        run: npm test  # Replace with your test command

  deploy:
    needs: test  # Only deploy if tests pass
    runs-on: ubuntu-latest
    steps:
      - name: Trigger deployment
        run: |
          RESPONSE=$(curl -s -X POST \
            -H "Authorization: Bearer ${{ secrets.CLOUDAIPILOT_TOKEN }}" \
            -H "Content-Type: application/json" \
            "https://api.cloudaipilot.com/v1/sites/${{ secrets.SITE_ID }}/deploy")
          echo "Deploy triggered: $RESPONSE"

      - name: Wait for deployment to complete
        run: |
          for i in $(seq 1 30); do
            STATUS=$(curl -s \
              -H "Authorization: Bearer ${{ secrets.CLOUDAIPILOT_TOKEN }}" \
              "https://api.cloudaipilot.com/v1/sites/${{ secrets.SITE_ID }}/deployments/latest" \
              | jq -r '.status')
            echo "Status: $STATUS"
            if [ "$STATUS" = "completed" ]; then
              echo "Deployment succeeded"
              exit 0
            fi
            if [ "$STATUS" = "failed" ]; then
              echo "Deployment failed"
              exit 1
            fi
            sleep 10
          done
          echo "Deployment timed out"
          exit 1

CI/CD secrets to set:

  • CLOUDAIPILOT_TOKEN — your API token
  • SITE_ID — the ID of your site

Pattern 3: GitLab CI — deploy stage

stages:
  - test
  - deploy

test:
  stage: test
  script:
    - npm test  # Replace with your test command

deploy:
  stage: deploy
  only:
    - main
  script:
    - |
      curl -s -X POST \
        -H "Authorization: Bearer $CLOUDAIPILOT_TOKEN" \
        "https://api.cloudaipilot.com/v1/sites/$SITE_ID/deploy"
    - |
      for i in $(seq 1 30); do
        STATUS=$(curl -s \
          -H "Authorization: Bearer $CLOUDAIPILOT_TOKEN" \
          "https://api.cloudaipilot.com/v1/sites/$SITE_ID/deployments/latest" \
          | jq -r '.status')
        echo "Status: $STATUS"
        [ "$STATUS" = "completed" ] && exit 0
        [ "$STATUS" = "failed" ] && exit 1
        sleep 10
      done
      exit 1

GitLab CI/CD Variables to set:

  • CLOUDAIPILOT_TOKEN — your API token
  • SITE_ID — the ID of your site

Pattern 4: Backup before deploy

For production deployments where you want a backup before every code push:

- name: Create pre-deploy backup
  run: |
    BACKUP=$(curl -s -X POST \
      -H "Authorization: Bearer ${{ secrets.CLOUDAIPILOT_TOKEN }}" \
      "https://api.cloudaipilot.com/v1/servers/${{ secrets.SERVER_ID }}/backups")
    BACKUP_ID=$(echo $BACKUP | jq -r '.id')
    
    # Wait for backup to complete
    for i in $(seq 1 20); do
      STATUS=$(curl -s \
        -H "Authorization: Bearer ${{ secrets.CLOUDAIPILOT_TOKEN }}" \
        "https://api.cloudaipilot.com/v1/backups/$BACKUP_ID" \
        | jq -r '.status')
      [ "$STATUS" = "completed" ] && break
      sleep 15
    done
    
    echo "Backup complete. Proceeding to deploy."

- name: Trigger deployment
  run: |
    curl -X POST \
      -H "Authorization: Bearer ${{ secrets.CLOUDAIPILOT_TOKEN }}" \
      "https://api.cloudaipilot.com/v1/sites/${{ secrets.SITE_ID }}/deploy"

Related articles