CI/CD for Databases with Azure DevOps and GitHub
Many teams use GitHub for source control but prefer Azure DevOps Pipelines for CI/CD. Azure Pipelines can seamlessly trigger from GitHub repositories, giving you the best of both platforms.
This guide walks you through setting up Atlas's automated database schema migrations with code hosted on GitHub and pipelines running on Azure DevOps.
Prerequisites
Installing Atlas
- macOS + Linux
- Homebrew
- Docker
- Windows
- CI
- Manual Installation
To download and install the latest release of the Atlas CLI, simply run the following in your terminal:
curl -sSf https://atlasgo.sh | sh
Get the latest release with Homebrew:
brew install ariga/tap/atlas
To pull the Atlas image and run it as a Docker container:
docker pull arigaio/atlas
docker run --rm arigaio/atlas --help
If the container needs access to the host network or a local directory, use the --net=host flag and mount the desired
directory:
docker run --rm --net=host \
-v $(pwd)/migrations:/migrations \
arigaio/atlas migrate apply
--url "mysql://root:pass@:3306/test"
Download the latest release and move the atlas binary to a file location on your system PATH.
GitHub Actions
Use the setup-atlas action to install Atlas in your GitHub Actions workflow:
- uses: ariga/setup-atlas@v0
with:
cloud-token: ${{ secrets.ATLAS_CLOUD_TOKEN }}
Other CI Platforms
For other CI/CD platforms, use the installation script. See the CI/CD integrations for more details.
After installing Atlas locally, log in to your organization by running the following command:
atlas login
Setting up Azure DevOps
- Create an Azure DevOps organization if you don't have one already.
- Create a new project in your Azure DevOps organization.
- Add the Atlas extension to your organization from the Azure DevOps Marketplace.
Connecting GitHub to Azure DevOps
To trigger Azure DevOps pipelines from GitHub repositories, you need to create a service connection:
- In your Azure DevOps project, go to Project Settings → Service connections.
- Click New service connection and select GitHub.
- Choose OAuth or Personal Access Token authentication method.
- If using Personal Access Token, create a GitHub personal access token with
reposcope. - Name your service connection (e.g., "GitHub Connection").
The GitHub service connection allows the AtlasAction task to post migration lint results directly as comments on your GitHub
pull requests. This provides immediate feedback to developers without requiring them to navigate to Azure DevOps to view the
results. Make sure to use the exact name of your service connection in the githubConnection parameter below.
Creating an Atlas Cloud bot token
To report CI run results to Atlas Cloud, create an Atlas Cloud bot token by following these instructions. Copy the token and store it as a secret using the following steps.
Creating secrets in Azure DevOps
In your Azure DevOps project, go to Pipelines → Library:
- Create a variable group named "atlas-vars".
- Add the following variables:
ATLAS_TOKEN- Your Atlas Cloud bot token (mark as secret)DB_URL- Your database connection string (mark as secret)