Multi environment deployment best practice

I have 2 projects - one for staging and production. I want to deploy the same agent to staging and production with different secrets.
What is the recommended best practice? How to deal with multiple livekit.toml files?
How to automate it in github actions?

The recommended pattern is one deployment per LiveKit Cloud project, using the same codebase but separate deployments and secrets per environment.

When you run lk agent create, a livekit.toml is generated and tied to the currently selected default project. For staging and production, link both projects in the CLI and switch with lk project set-default before deploying. Each project gets its own deployment and independently managed secrets, as described in the Agent deployment quickstart.

@darryncampbell I am still a bit confused…

  1. lk agent create would create livekit.tomlfile. Should this file be check in to the repo? Or should this file be created from scratch everytime?
  2. If livekit.tomlshould be checked into the repo, how can I check in multiple tomlfiles for different projects?
  3. For future deployments using lk agent deploy, how can I point to the right tomlfile when I have multiple tomlfiles?

Sure, so:

  1. Create the agent locally
  2. Run lk cloud auth to authenticate against both your dev and prod cloud projects
  3. Deploy the agent to your cloud dev environment (lk agent create, then select the appropriate cloud project and appropriate secrets / env file - note that the LiveKit URL, Key and Secret in the selected env file should match your cloud dev environment). This creates a livekit.toml file, which you can rename to livekit.toml.dev. This also deploys your agent to dev
  4. Deploy the agent to your cloud prod environment (lk agent create, then repeat the steps above, renaming the resulting livekit.toml to livekit.toml.prod)
  5. To redeploy your dev agent run lk agent deploy –secrets-file <your dev env file> –config <your dev toml file>
  6. To redeploy your prod agent run lk agent deploy –secrets-file <your prod env file> –config <your prod toml file>
  7. Make sure you don’t have environment variables defined for LIVEKIT_URL etc. Otherwise these will be picked up in preference to the above. This also means you don’t have to worry about lk project set-default

@darryncampbell That was helpful. Two quick clarification:

  1. The environment file should have LIVEKIT_URL, Key and Secret during lk agent createbut not during future lk agent deploy?
  2. Any harm in having them assuming they are no change in their values?

Each project has its own URL, key, and secret so your prod and dev will have unique values, but those will not change (they are associated with the project, not the agent)

is there an example of deploying a livekit agent using github action?

I think this is what you are looking for:

This is great! I like the Deploy an existing agent on file change example. Is there a way to specifiy which tomlfile to use in that github action example? I will have multiple livekit.toml files, oneper environment. I want to point the github action to the right tomlfile as needed.