Course contentsShow
← AI Engineering
Lesson 904 of 1,88622. Testing and CI/CD for AI SystemsFree lesson

CI Environment Setup and Secrets

Configure CI environments with API keys, credentials, and test accounts securely.

CI Environment Setup and Secrets

You'll learn how to securely configure continuous integration environments with the API keys, credentials, and test accounts your AI pipelines need to run automated tests.

The Problem with Secrets in CI

When you run tests locally, you might use a .env file with your OpenAI API key, database password, or test account credentials. But when GitHub Actions (or another CI platform) runs your tests automatically, it needs those same secrets—without you hardcoding them in your repository for everyone to see.

Think of it like a valet key: you need to give your CI environment just enough access to run tests, but not your production keys or master credentials.

How CI Secrets Work

Most CI platforms provide a secrets management system:

  1. Store secrets in the platform: Add your OPENAI_API_KEY, PINECONE_API_KEY, or database credentials through the CI provider's web interface or CLI
  2. Reference them in workflows: Your GitHub Actions YAML can access secrets without exposing their values
  3. Secrets stay encrypted: They're never logged or visible in test output

Example pattern in .github/workflows/test.yml:

env:
  OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
  TEST_DB_URL: ${{ secrets.TEST_DB_URL }}

Best Practices

  • Use dedicated test API keys with rate limits and isolated from production
  • Create separate test accounts for external services
  • Never echo or log secret values in test output
  • Rotate secrets regularly and immediately if exposed
  • Set minimal permissions on service accounts used in CI

Key Takeaway: Secure CI secrets management lets your automated AI tests authenticate to external services safely, using encrypted storage and environment variables instead of hardcoded credentials.