Preview projects are temporary Lightdash projects where you can safely experiment with your metrics, dimensions and charts without affecting your production project.
lightdash preview
from inside your projectcmd
+ click
to open the preview link from your terminal. Once you’re in Lightdash go to Explore
—> Tables
, then click on the model(s) you just updated to see your changes and play around with them.
profiles.yml
file for your current dbt project. This can be a problem if you’re using a local database that your laptop can reach but your Lightdash instance cannot.github action
and get Lightdash to create new dynamic preview
projects automatically when a new pull request
is created, and it will automatically delete the preview
project when the pull request
is closed or merged.
Settings
, on the left sidebar, click on Secrets
under Security
. Now click on the New repository secret
LIGHTDASH_API_KEY
Settings
> Personal Access Tokens
. This is the token you’ll put in for LIGHTDASH_API_KEY
.
LIGHTDASH_PROJECT
https://eu1.lightdash.cloud/projects/3538ab33-dc90-aabb-bc00-e50bba3a5f69/tables
, then 3538ab33-dc90-45f0-aabb-e50bba3a5f69
is your LIGHTDASH_PROJECT
LIGHTDASH_URL
https://eu1.lightdash.cloud
or https://app.lightdash.cloud
for Lightdash Cloud users (check the URL to your Lightdash project). If you self-host, this should be your own custom domain.
DBT_PROFILES
profiles.yml
file. You can see what’s in there by typing cat ~/.dbt/profiles.yml
in your terminal.
prod
and dev
profile, you probably want to use the information from your prod
profile for your GitHub action.
DBT_PROFILES
secret.
BigQuery
GOOGLE_APPLICATION_CREDENTIALS
Add the service account credentials (the JSON file) that you want to use for your GitHub action. It should look something like this:DBT_PROFILES
Copy-paste this template into the secret and fill out the details.This will always use this project connection in your GitHub actions. If you want your preview projects to have different connection settings depending on the user that opened the pull request (dev profiles), then see what you need to add to your secret in this guide.Postgres
Redshift
Snowflake
DataBricks
Actions
menu, and click on Configure
Start commit
Do the same with this close-preview.yml file.
pull request
, a new preview
project with your branch
name will be created on your organization. Everytime you make a change to that branch, the preview environment will get updated. Once you close or merge your pull request
, the preview
project will get deleted.
You can see the log on Github actions
page
${{ github.actor }}
with ${{steps.get_pr_creator.outputs.result}}
.DBT_PROFILES
to have 1 target per developer. The target name should be their GitHub username.
--target
flag for the lightdash start-preview
command.
dbt_cloud_pr_<job_id>_<pr_id>
) for your preview project.
First we need to add an environment variable to your profile.yml file that will be used by dbt to connect to the correct schema.
dataset
instead of schema
.
Then we need to add a step in the GitHub action to fetch the pull request id.
1234
. You will need to replace this with the actual job id.