Skip to content
OpenSmartRoute
Skillv1.0.0

castai-ci-integration

Integrate CAST AI policy validation and cost checks into CI/CD pipelines. Use when adding CAST AI savings verification to GitHub Actions, validating Terraform plans, or gating deployments on cost thre

by jeremylongshore(0) 0 installs
Free
Sign in to install

Free account. Installing gives you the manifest plus copy-paste snippets.

See reviews

About

Imported from jeremylongshore/tons-of-skills-marketplace (plugins/saas-packs/castai-pack/skills/castai-ci-integration/SKILL.md). Install upstream with npx skills add jeremylongshore/tons-of-skills-marketplace --skill castai-ci-integration. Copyright stays with the author (MIT).

CAST AI CI Integration

Overview

Add CAST AI cost validation to CI/CD pipelines: verify savings thresholds, validate Terraform plans before apply, and gate deployments on autoscaler health.

Prerequisites

  • GitHub Actions enabled
  • CAST AI API key stored as repository secret
  • Terraform state accessible from CI (if using Terraform)

Instructions

Step 1: GitHub Actions -- Savings Gate

# .github/workflows/castai-check.yml
name: CAST AI Cost Check

on:
  pull_request:
    paths: ["terraform/**", "k8s/**"]
  schedule:
    - cron: "0 8 * * 1"  # Weekly Monday report

jobs:
  cost-check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Check CAST AI Savings
        env:
          CASTAI_API_KEY: ${{ secrets.CASTAI_API_KEY }}
          CASTAI_CLUSTER_ID: ${{ secrets.CASTAI_CLUSTER_ID }}
        run: |
          SAVINGS=$(curl -s -H "X-API-Key: ${CASTAI_API_KEY}" \
            "https://api.cast.ai/v1/kubernetes/clusters/${CASTAI_CLUSTER_ID}/savings")

          PERCENT=$(echo "$SAVINGS" | jq -r '.savingsPercentage')
          MONTHLY=$(echo "$SAVINGS" | jq -r '.monthlySavings')

          echo "### CAST AI Savings Report" >> $GITHUB_STEP_SUMMARY
          echo "- Monthly savings: \$${MONTHLY}" >> $GITHUB_STEP_SUMMARY
          echo "- Savings percentage: ${PERCENT}%" >> $GITHUB_STEP_SUMMARY

          # Fail if savings drop below threshold
          if (( $(echo "$PERCENT < 10" | bc -l) )); then
            echo "WARNING: Savings below 10% threshold"
            exit 1
          fi

      - name: Verify Agent Health
        env:
          CASTAI_API_KEY: ${{ secrets.CASTAI_API_KEY }}
          CASTAI_CLUSTER_ID: ${{ secrets.CASTAI_CLUSTER_ID }}
        run: |
          STATUS=$(curl -s -H "X-API-Key: ${CASTAI_API_KEY}" \
            "https://api.cast.ai/v1/kubernetes/external-clusters/${CASTAI_CLUSTER_ID}" \
            | jq -r '.agentStatus')

          if [ "$STATUS" != "online" ]; then
            echo "CAST AI agent is ${STATUS}, expected online"
            exit 1
          fi

Step 2: Terraform Plan Validation

  terraform-plan:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: hashicorp/setup-terraform@v3

      - name: Terraform Init & Plan
        working-directory: terraform/
        env:
          CASTAI_API_TOKEN: ${{ secrets.CASTAI_API_KEY }}
        run: |
          terraform init
          terraform plan -var-file=environments/prod.tfvars \
            -out=plan.tfplan -no-color | tee plan-output.txt

      - name: Check for Destructive Changes
        run: |
          if grep -q "will be destroyed" terraform/plan-output.txt; then
            echo "DESTRUCTIVE CHANGES DETECTED in CAST AI resources"
            exit 1
          fi

Step 3: Store Secrets

gh secret set CASTAI_API_KEY --body "your-api-key"
gh secret set CASTAI_CLUSTER_ID --body "your-cluster-id"

Error Handling

Issue Cause Solution
Secret not found Missing gh secret set Add secrets to repo
Savings check fails Cluster not onboarded Verify cluster ID is correct
Terraform init fails State backend misconfigured Check backend config
Agent offline in CI Key scope mismatch Use production API key

Output

The CI run publishes a redacted plan summary, agent-health decision, destructive-change result, immutable run URL, and named approver for any production promotion. Secrets remain in the CI secret store, are masked in logs, and are unavailable to untrusted pull-request code or forked workflows.

Examples

On a protected branch, run the plan with a scoped staging credential and fail when the parsed plan contains destructive changes or the agent is offline. Upload only the redacted plan artifact; require an environment approval before any apply job, and cancel the deployment when the approval or freshness window expires.

Resources

Next Steps

For deployment patterns, see castai-deploy-integration.

Use it

Copy one of these into your project. Installing also returns the manifest and these snippets.

yaml
targets:
  - https://api.opensmartroute.ai/api/v1/registry/jeremylongshore-tons-of-skills-marketplace-castai-ci-int-999c0c/manifest   # or paste the manifest below

Manifest

An Open Capability Manifest: the router reads it to know what this does, what it costs and when to pick it.

jeremylongshore-tons-of-skills-marketplace-castai-ci-int-999c0c.ocm.jsonjson
{
  "ocm": "1",
  "id": "jeremylongshore-tons-of-skills-marketplace-castai-ci-int-999c0c",
  "kind": "skill",
  "name": "castai-ci-integration",
  "description": "Integrate CAST AI policy validation and cost checks into CI/CD pipelines. Use when adding CAST AI savings verification to GitHub Actions, validating Terraform plans, or gating deployments on cost thresholds. Trigger with phrases like \"cast ai CI\", \"cast ai github actions\", \"cast ai terraform CI\", \"cast ai pipeline\".",
  "publisher": "jeremylongshore",
  "version": "1.0.0",
  "capabilities": {
    "domains": [
      "general"
    ],
    "tags": [
      "skill-md",
      "saas",
      "kubernetes",
      "cost-optimization",
      "castai",
      "skills-sh"
    ],
    "languages": [
      "en"
    ]
  },
  "quality_prior": 0.6,
  "examples": [
    "Integrate CAST AI policy validation and cost checks into CI/CD pipelines. Use when adding CAST AI savings verification to GitHub Actions, validating Terraform plans, or gating deployments on cost thresholds. Trigger with phrases like \"cast ai CI\", \"cast ai github actions\", \"cast ai terraform CI\", \"cast ai pipeline\"."
  ],
  "primary": false,
  "metadata": {
    "source": {
      "provider": "skills.sh",
      "repository": "https://github.com/jeremylongshore/tons-of-skills-marketplace",
      "path": "plugins/saas-packs/castai-pack/skills/castai-ci-integration/SKILL.md",
      "ref": "HEAD",
      "url": "https://github.com/jeremylongshore/tons-of-skills-marketplace/blob/HEAD/plugins/saas-packs/castai-pack/skills/castai-ci-integration/SKILL.md",
      "key": "jeremylongshore/tons-of-skills-marketplace/plugins/saas-packs/castai-pack/skills/castai-ci-integration/SKILL.md"
    },
    "compatibility": "Designed for Claude Code",
    "allowed_tools": [
      "Read,",
      "Write,",
      "Edit,",
      "Bash(gh:*)"
    ],
    "license": "MIT"
  },
  "instructions": "# CAST AI CI Integration\n\n## Overview\n\nAdd CAST AI cost validation to CI/CD pipelines: verify savings thresholds, validate Terraform plans before apply, and gate deployments on autoscaler health.\n\n## Prerequisites\n\n- GitHub Actions enabled\n- CAST AI API key stored as repository secret\n- Terraform state accessible from CI (if using Terraform)\n\n## Instructions\n\n### Step 1: GitHub Actions -- Savings Gate\n\n```yaml\n# .github/workflows/castai-check.yml\nname: CAST AI Cost Check\n\non:\n  pull_request:\n    paths: [\"terraform/**\", \"k8s/**\"]\n  schedule:\n    - cron: \"0 8 * * 1\"  # Weekly Monday report\n\njobs",
  "cost": {
    "context_tokens": 1055
  }
}

Fetch it by URL: GET /api/v1/registry/jeremylongshore-tons-of-skills-marketplace-castai-ci-int-999c0c/manifest?version=1.0.0

Reviews

Star ratings from people who tried it. One review per account; edit yours any time.

No reviews yet. Install it, try it, and be the first to rate it.