Skip to content

CI/CD Integration

Integrate Ops Atlas with your CI/CD pipelines.

GitHub Actions

yaml
name: Deploy

on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      
      - name: Build and Push Docker Image
        run: |
          docker build -t myapp:${{ github.sha }} .
          docker push myapp:${{ github.sha }}
      
      - name: Deploy via Ops Atlas
        run: |
          curl -X POST "${{ secrets.OPSATLAS_URL }}/api/v1/deployments" \
            -H "Authorization: Bearer ${{ secrets.OPSATLAS_TOKEN }}" \
            -H "Content-Type: application/json" \
            -d '{
              "service": "my-app",
              "version": "${{ github.sha }}",
              "strategy": "rolling"
            }'
      
      - name: Wait for Deployment
        run: |
          curl -X GET "${{ secrets.OPSATLAS_URL }}/api/v1/deployments/latest?service=my-app" \
            -H "Authorization: Bearer ${{ secrets.OPSATLAS_TOKEN }}" \
            --retry 30 \
            --retry-delay 10 \
            --retry-all-errors

GitLab CI

yaml
stages:
  - build
  - deploy

deploy:
  stage: deploy
  script:
    - |
      curl -X POST "$OPSATLAS_URL/api/v1/deployments" \
        -H "Authorization: Bearer $OPSATLAS_TOKEN" \
        -H "Content-Type: application/json" \
        -d "{\"service\": \"my-app\", \"version\": \"$CI_COMMIT_SHA\"}"
  only:
    - main

Jenkins

groovy
pipeline {
    agent any
    stages {
        stage('Deploy') {
            steps {
                script {
                    def response = httpRequest(
                        url: "${env.OPSATLAS_URL}/api/v1/deployments",
                        httpMode: 'POST',
                        customHeaders: [[name: 'Authorization', value: "Bearer ${env.OPSATLAS_TOKEN}"]],
                        contentType: 'APPLICATION_JSON',
                        requestBody: """{"service": "my-app", "version": "${env.GIT_COMMIT}"}"""
                    )
                }
            }
        }
    }
}

Webhooks

Receive deployment notifications:

bash
# Register webhook
curl -X POST "$OPSATLAS_URL/api/v1/webhooks" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{
    "url": "https://your-server.com/webhook",
    "events": ["deployment.started", "deployment.completed", "deployment.failed"]
  }'

Released under the MIT License.