.NET › CI/CD, Publishing & Deployment
How do you securely manage secrets (connection strings, API keys) in a CI/CD pipeline without committing them to source control?
IntermediateAnswer
CI/CD platforms provide encrypted secret storage (GitHub Actions Secrets, Azure DevOps variable groups with secret variables, GitLab CI/CD variables) injected as environment variables only during pipeline execution, never exposed in logs or the repository itself -- combined with cloud-native secret managers (Azure Key Vault, AWS Secrets Manager) for runtime application secrets, keeping build-time and run-time secret concerns properly separated.
# GitHub Actions: referencing a repository secret
- name: Deploy
env:
CONNECTION_STRING: ${{ secrets.PROD_DB_CONNECTION_STRING }}
run: dotnet run --project deploy-toolReal-world example A pipeline deploying to Azure retrieves its deployment credentials from GitHub Actions Secrets rather than a hardcoded config file, and the application itself retrieves its database connection string from Azure Key Vault at runtime rather than from pipeline-injected environment variables.