Version: Latest

Setting up CI/CD

This page explains how to set up a Continuous Integration (CI) and Continuous Deployment (CD) pipeline.

Overview

Continuous Integration (CI) is the practice of merging in code changes frequently and automatically testing changes as they are committed. Continuous Deployment (CD) means automatically deploying integrated changes to a staging or production environment. Together, they allow you to make more frequent improvements to your assistant and efficiently test and deploy those changes.

This guide will cover what should go in a CI/CD pipeline, specific to a Rasa project. How you implement that pipeline is up to you. There are many CI/CD tools out there, such as GitHub Actions, GitLab CI/CD, Jenkins, and CircleCI. We recommend choosing a tool that integrates with whatever Git repository you use.

Example Rasa Pro CI/CD pipeline

An example Github Actions workflow is shown below:

name: Rasa Pro CI/CD Pipeline
on:
push:
branches:
- main
paths:
- 'data/**'
- 'domain/**'
jobs:
train_test_deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Make sure to use the exact same Rasa version as in your TEST/PROD environment
- name: Pull Rasa Pro image
run: |
docker pull europe-west3-docker.pkg.dev/rasa-releases/rasa-pro/rasa-pro:3.8.0-latest
# Store the Rasa Pro license string as a secret RASA_PRO_LICENSE
- name: Train Rasa model with Rasa Pro
run: |
docker run -v ${GITHUB_WORKSPACE}:/app \
-e RASA_PRO_LICENSE=${RASA_PRO_LICENSE} \
-e RASA_TELEMETRY_ENABLED=false \
europe-west3-docker.pkg.dev/rasa-releases/rasa-pro/rasa-pro:3.8.0-latest \
train --domain /app/domain --data /app/data --out /app/models
env:
RASA_PRO_LICENSE: ${{ secrets.RASA_PRO_LICENSE }}
# Make sure to use your action server image and point rasa to the folder with your e2e tests (e.g. tests/e2e_test_cases.yml)
# Use the same Rasa version as in the previous step
# Your endpoints file should contain the action server url (e.g. http://action_server:5055/webhook)
- name: Start Action Server and Test Rasa model with E2E tests
run: |
# Start the action server in the background
docker run -d -p 5055:5055 --name action_server <YOUR-ACTION-SERVER-IMAGE>
# Wait for the action server to become ready with a timeout
echo "Waiting for action server to be ready..."
timeout=60
while ! curl --output /dev/null --silent --fail http://localhost:5055/health; do
printf '.'
sleep 5
timeout=$((timeout-5))
if [ "$timeout" -le 0 ]; then
echo "Action server did not become ready in time."
echo "Action server logs:"
docker logs action_server
exit 1
fi
done
echo "Action server is ready."
# Run E2E tests in the same step to ensure the action server is still running
# Use container linking to allow communication
docker run -v ${GITHUB_WORKSPACE}:/app \
--link action_server:action_server \
-e RASA_PRO_LICENSE=${RASA_PRO_LICENSE} \
-e RASA_TELEMETRY_ENABLED=false \
europe-west3-docker.pkg.dev/rasa-releases/rasa-pro/rasa-pro:3.8.0-latest \
test e2e /app/tests/e2e_test_cases.yml --model /app/models --endpoints /app/endpoints.yml
env:
RASA_PRO_LICENSE: ${{ secrets.RASA_PRO_LICENSE }}
# if tests fail, next steps won't be executed and model won't be uploaded to the bucket
# Authenticate to Google Cloud again to avoid permission issues and use a service account with Storage Object Creator role
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v0.4.0
with:
credentials_json: '${{ secrets.GCP_SA_KEY }}'
- name: Configure Google Cloud project
run: |
echo $GCP_SA_KEY | gcloud auth activate-service-account --key-file=-
env:
GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }}
# Upload the trained model to the Model Storage bucket associated with your deployment
- name: Upload model to Google Cloud Storage
run: |
gsutil cp -r models/* gs://my-model-storage/