Incorporate Deploy CLI into Build Environment
Auth0 offers a Deploy CLI tool that we recommend you incorporate into your build system. The Deploy CLI tool allows you to:
- Deploy using the command line
- Create a repository to store your deployment configuration
- Create a set of configuration files for each environment (e.g., development, production)
- Have a deployment build for each environment that updates a local copy of the deployment configuration repository on your continuous integration server
Auth0 tenant layout
We recommend that you have a separate Auth0 tenant/account for each environment you have. For example, you might have the following environments and Auth0 tenants:
Your deploy configuration repository
Your configuration repository should continue a specific set of files based on how you've chosen to import/export your tenant configuration information:
You should have at least one branch for each tenant/account in your repository, which allows you to make changes without deploying them (the changes would only deploy when you merged your branch into the master, or primary, branch). With this setup, you can have a continuous integration task for each environment that automatically deploys changes to the targeted environment whenever the master branch receives updates.
Your workflow would, therefore, look something like this:
- Make changes to development.
- Merge changes to testing (or
- Test changes to
uat. When ready, move and merge the changes to
staging. When ready, move and merge the changes to
You may want to set your production environment to deploy only when triggered manually.
Your continuous integration (CI) server configuration
Your CI server should have a different deploy task and config for each environment. Since each tenant/account needs to have the
auth0-deploy-cli-extension installed and using a different domain, client ID, and secret, you will need to create individual configurations -- this has the bonus of helping you avoid accidental deployments to the wrong environment.
The deploy task should do the following:
- Update the local repo to include latest the latest changes (each environment should have its own branch of the repository that can later be merged with other branches)
- If there are changes, call
- Run a suite of tests to confirm configuration is working.
- (Optional) Merge to next branch (e.g.
Use keyword mappings to handle differences between the environments
You should not have to store differences between environments in the Deploy Configuration Repository. Use the keyword mappings to allow the repository to be environment agnostic, and save the differences in the separate
config.json files for each environment on the CI server.
For more information, see Environment Variables and Keyword Mappings.