Continuous Integration & Delivery
Automating deployments to Rivet with GitHub Actions allows you to seamlessly deploy your application whenever you push changes to your repository. This guide will walk you through setting up continuous delivery for your Rivet project.
Setup
Step 1: Prepare Your Application
Before setting up continuous delivery, you need a working Rivet application:
-
Set up your application using one of the following guides:
-
Make sure you have a working
rivet.json
configuration file in your project -
Test your deployment locally to verify everything works:
Command Line
Step 2: Generate a Rivet Cloud Token
To authenticate your GitHub Actions workflow with Rivet:
- Go to your Rivet Dashboard
- Navigate to your project > Settings
- Under the "Cloud Token" section, click "Generate", and copy the generated token
Next, add the token to GitHub Actions Secrets:
- In your GitHub repository, go to Settings > Secrets and variables > Actions
- Click "New repository secret"
- Set the name to
RIVET_CLOUD_TOKEN
- Paste your Rivet Cloud Token as the value
- Click "Add secret"
For more information on Rivet tokens, see the Tokens documentation.
Step 3: Create GitHub Actions Workflow
Create a .github/workflows
directory in your repository if it doesn't already exist, then add a deploy.yml
file with the following content:
Step 4: Push Changes to Your Repository
Now that your workflow is set up, it's time to test it:
The workflow will automatically deploy your application to an environment with the same name as your branch.
Environment Mapping
By default, the workflow deploys to environments matching the branch name:
prod
branch →prod
environmentstaging
branch →staging
environment
You can create additional environments in the Rivet Dashboard to match your branch strategy.
Step 5: Verify Deployment
After pushing your changes:
- Navigate to your GitHub repository and click the "Actions" tab
- Find the latest workflow run and check its status
- In the Rivet Dashboard, go to your project's environment
- Under the "Versions" tab, you should see your latest deployment with the commit SHA included in the tags
Tips
Selective Branch Deployment
If you only want to deploy specific branches, modify the workflow trigger:
Custom Environment Mapping
To deploy to specific environments regardless of branch name:
Using the Latest Build in Your Application
The Rivet CLI automatically adds a current=true
tag to the most recent successful build. You can use this tag to always reference the latest build when creating actors:
This approach ensures your application always uses the most recent build deployed through your CI/CD pipeline.