Hi, with Livekit Cloud Agents, is it possible to d...
# ask-ai
g
Hi, with Livekit Cloud Agents, is it possible to deploy new versions of an Agent on push to a particular github branch? Or, to Authenticate with Livekit Cloud using a key, in order to integrate the CLI into a build runner?
t
Thanks for reaching out, Justyn. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
If you want to deploy new versions of a LiveKit Cloud Agent whenever you push to a GitHub branch, the
lk agent deploy
command is your friend! You can include it in your CI/CD pipeline to build and deploy your agent straight from your repo. The best part? It uses a rolling deployment strategy, so your users won’t experience any downtime — new instances take over new sessions while the old ones finish up their active sessions before shutting down. To make this deployment automatic on a GitHub push, just plug
lk agent deploy
into your GitHub Actions workflow. For example, you can trigger it on pushes to your
main
branch, authenticate the LiveKit CLI, and then deploy. Here’s a handy example of what that workflow might look like:
Copy code
name: Deploy LiveKit Agent
on:
  push:
    branches: [ main ]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Set up Node.js (if required for your agent)
        uses: actions/setup-node@v4
        with:
          node-version: '20'

      - name: Install LiveKit CLI
        run: npm install -g @livekit/cli

      - name: Authenticate with LiveKit Cloud
        run: |
          echo "$LIVEKIT_API_KEY" | lk cloud auth --api-key --stdin
          # Link the correct project if needed
          lk project set-default "<your-project-name>"
        env:
          LIVEKIT_API_KEY: ${{ secrets.LIVEKIT_API_KEY }}
          LIVEKIT_API_SECRET: ${{ secrets.LIVEKIT_API_SECRET }}

      - name: Deploy Agent
        run: lk agent deploy
Just make sure your LiveKit CLI is properly authenticated and set up in your CI environment before running the deploy command. You’ll want to save your LiveKit API key and secret as GitHub secrets (
LIVEKIT_API_KEY
and
LIVEKIT_API_SECRET
) in your repo’s settings. If you’d like, I’m here to help you with setting up those secrets or tweaking this workflow for a different kind of agent. Just let me know! Sources: .gitlab/ci/deploy.yml | Deploying to production | LiveKit Docs | Agent deployment CLI reference | LiveKit Docs
g
But explain how the livekit CLI can be "properly authenticated and set up" in a Github Actions workflow
t
Hey there! To get your LiveKit CLI authenticated in a GitHub Actions workflow, the best way is to use environment variables to safely pass your LiveKit credentials (
LIVEKIT_API_KEY
,
LIVEKIT_API_SECRET
, and
LIVEKIT_URL
) to the CLI. The usual
lk cloud auth
command depends on a browser-based login, which doesn’t really work in headless CI setups like GitHub Actions. So, here’s a friendly tip: set up the LiveKit CLI to use your project credentials directly through environment variables:
Copy code
env:
  LIVEKIT_URL: ${{ secrets.LIVEKIT_URL }}
  LIVEKIT_API_KEY: ${{ secrets.LIVEKIT_API_KEY }}
  LIVEKIT_API_SECRET: ${{ secrets.LIVEKIT_API_SECRET }}
The LiveKit CLI automatically picks up these environment variables for authentication when you run commands like
lk room list
or
lk token create
. Just make sure to save these values as GitHub Secrets in your repo settings so they stay safe and private. Here’s a simple example of a GitHub Actions workflow step:
Copy code
- name: List LiveKit rooms
  run: lk room list
  env:
    LIVEKIT_URL: ${{ secrets.LIVEKIT_URL }}
    LIVEKIT_API_KEY: ${{ secrets.LIVEKIT_API_KEY }}
    LIVEKIT_API_SECRET: ${{ secrets.LIVEKIT_API_SECRET }}
This way, you skip the interactive browser login from
lk cloud auth
, making your automation smooth and hassle-free. It’s the recommended approach for using the LiveKit CLI in automated environments. If you have any questions or need a hand, just let me know! Sources: README.md | LiveKit CLI Setup | LiveKit Docs | Accepting incoming calls | LiveKit Docs | Accepting incoming calls | LiveKit Docs
g
Where in the docs does it explain that the Livekit CLI can pick up these environment variables instead of using browser auth?
t
Hey there! Just a quick heads-up: the LiveKit CLI can use environment variables to handle authentication instead of going through the browser. Here are the environment variables it recognizes and uses automatically when you run commands: • `LIVEKIT_URL`: This is the WebSocket URL for your LiveKit server or Cloud project. • `LIVEKIT_API_KEY`: Your LiveKit project's API key. • `LIVEKIT_API_SECRET`: The API secret tied to your LiveKit project. For example, you can set these up in your environment like this:
Copy code
export LIVEKIT_URL=wss://your-project.livekit.cloud
export LIVEKIT_API_KEY=your-api-key
export LIVEKIT_API_SECRET=your-api-secret
These variables are picked up directly by the CLI tools and SDKs, mapping to the
--url
,
--api-key
, and
--api-secret
options. You'll find this approach used in several example repositories and docs, like those for setting up inbound and outbound calls with LiveKit Agents. If you'd like, I can share some links to specific examples or help clarify anything else—just let me know! Sources: livekit-agents/livekit/agents/cli/cli.py | rover/cam_publish.sh | web/.env.sample | .env.example | Accepting incoming calls | LiveKit Docs