# dbt Impact Report

## Introduction

Select Star's dbt Impact Report allows you to make model changes with confidence. The Impact Report shows downstream items for your dbt model changes right in your pull request, so you can view potential impact before making changes and prevent downstream breakages.

dbt Impact Report is available via GitHub Actions. Follow the instructions at <https://github.com/selectstar/dbt-impact-report-action> or below to set up the GitHub Action.

<figure><img src="https://3470314135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgAiVthA_yg9UXKuhyY%2Fuploads%2Fgit-blob-f14836914702bdfd55955424d5694a57c67305a9%2FScreenshot%202023-10-06%20at%2014.54.31.png?alt=media" alt=""><figcaption></figcaption></figure>

## Before You Start

1. dbt MUST be **set up as a separate data source**

<div data-full-width="true"><figure><img src="https://3470314135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgAiVthA_yg9UXKuhyY%2Fuploads%2Fgit-blob-cdc439c17723dedf85a46174b441d31adc876963%2FCleanShot%202023-11-27%20at%2016.49.08%402x.png?alt=media" alt="" width="563"><figcaption></figcaption></figure></div>

1. **Select Star API Token** - this is required for the Action to use Select Star's APIs. See [API Token](https://docs.selectstar.com/select-star-api/authentication).
2. **Select Star Data Source GUID** - this is the GUID of the dbt data source corresponding to the repository you're adding the Action to.
   1. You can get the GUID by going into **Admin > Data** and selecting the dbt data source. The GUID will be in the URL and look like `ds_example` .

<div data-full-width="true"><figure><img src="https://3470314135-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MgAiVthA_yg9UXKuhyY%2Fuploads%2Fgit-blob-2af998962b9777d0c367fe6e10574499bd663c0d%2FMonosnap%20dbt%20from%20GH%20%7C%20Select%20Star%202023-11-29%2014-10-11.png?alt=media" alt=""><figcaption></figcaption></figure></div>

## Configure the GitHub Action

1. If you don't already have it, create repository secrets in your repo:
   1. `SELECTSTAR_API_TOKEN` with the value of the API Token from the prerequisites.
2. Add the Select Star GitHub Action to your workflow:
   1. Create a workflow file in your repo
   2. Add the following code to the workflow file

{% code lineNumbers="true" %}

```yaml
name: Select Star dbt impact report

on:
  pull_request:
    types: [opened, edited, synchronize, reopened]

jobs:
  create-impact-report:
    name: Create the impact report for dbt projects
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write 
    steps:
      - name: Run Action
        uses: selectstar/dbt-impact-report-action@v1
        with:
          GIT_REPOSITORY_TOKEN: ${{secrets.GITHUB_TOKEN}}   # no need to change, GitHub will handle it as it is
          SELECTSTAR_API_TOKEN: ${{secrets.SELECTSTAR_API_TOKEN}}
          SELECTSTAR_API_URL: YOUR INSTANCE API URL   # (e.g.: https://api.production.selectstar.com)
          SELECTSTAR_WEB_URL: YOUR INSTANCE WEB URL   # (e.g.: https://app.selectstar.com)
          SELECTSTAR_DATASOURCE_GUID: YOUR DBT DATA SOURCE GUID  # (e.g.: ds_aRjCTzAf4dPNigiV87Uggq)
```

{% endcode %}

{% hint style="warning" %}
Make sure the Datasource's GUID you add to the Github Workflow is the one corresponding to your DBT data source. Adding other GUIDs will not yield the right results in the report.
{% endhint %}

## Test it Out

After configuring the GitHub action, test out the dbt Impact Report by creating a pull request with any change to a dbt model file in the repo. You should see the action running and a new comment generated on the pull request with the Impact report.
