> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dqlabs.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Setup

> Step-by-step guide to adding the Prizm dbt Impact Analysis GitHub Action to a repository, including secrets, variables, and the workflow file.

<script type="application/ld+json">
  {`{
            "@context": "https://schema.org",
            "@type": "TechArticle",
            "headline": "GitHub Action Setup",
            "description": "Step-by-step guide to adding the Prizm dbt Impact Analysis GitHub Action to a repository, including secrets, variables, and the workflow file.",
            "url": "https://docs.dqlabs.ai/integrations/githubaction/setup",
            "publisher": {
              "@type": "Organization",
              "name": "DQLabs Inc",
              "logo": "https://media.brand.dev/332adc35-5bc4-4d2b-bf78-256aa4a5e414.svg"
            }
            }`}
</script>

## Adding the GitHub Action to your repository

The Prizm dbt Impact Analysis action is configured entirely within your dbt GitHub repository. There is no Prizm portal configuration required. Setup involves three steps: gathering the required values, adding secrets and variables to the repository, and committing the workflow file.

### Prerequisites

* GitHub Actions enabled on the dbt repository
* The repository's default GitHub Actions token must have **read and write** permissions for pull requests — see [GitHub documentation](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/enabling-features-for-your-repository/managing-github-actions-settings-for-a-repository#configuring-the-default-github_token-permissions)
* A dbt connection configured in Prizm with lineage data for the monitored repository

***

## Step 1: Gather required values

| Value              | Where to find it                                                                                   |
| ------------------ | -------------------------------------------------------------------------------------------------- |
| `PRIZM_TOKEN`      | Prizm portal → **Settings → Organization → Token** — copy an existing token or create a new one    |
| `TOKEN`            | A GitHub Personal Access Token (PAT) with `repo` scope — needed to write comments on pull requests |
| `CLIENT_LINK_URL`  | Your Prizm tenant URL (e.g., `https://benchmark.qa.prizmdata.ai`)                                  |
| `DBT_MCP_BASE_URL` | Your Prizm tenant URL (same as `CLIENT_LINK_URL`)                                                  |

***

## Step 2: Add secrets and variables to the repository

In your GitHub repository, go to **Settings → Secrets and variables → Actions**.

**Create the following Secrets:**

| Name          | Value                                               |
| ------------- | --------------------------------------------------- |
| `PRIZM_TOKEN` | Your Prizm API token                                |
| `TOKEN`       | Your GitHub PAT with pull request write permissions |

**Create the following Variables:**

| Name               | Value                 |
| ------------------ | --------------------- |
| `CLIENT_LINK_URL`  | Your Prizm tenant URL |
| `DBT_MCP_BASE_URL` | Your Prizm tenant URL |

<Note>
  `PRIZM_TOKEN` and `TOKEN` must be stored as **Secrets**, not Variables — they are sensitive credentials. `CLIENT_LINK_URL` and `DBT_MCP_BASE_URL` are non-sensitive and are stored as Variables.
</Note>

***

## Step 3: Add the workflow file

Create the file `.github/workflows/dbt-impact-analysis.yml` in your dbt repository with the following content:

```yaml theme={null}
name: "DBT Impact Analysis on PR"

on:
  pull_request:
    paths:
      - '**/*.sql'
      - '**/*.yml'
      - '**/*.csv'

permissions:
  contents: read
  pull-requests: write

jobs:
  impact-analysis:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout PR code (head)
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Get changed DBT files
        id: changes
        uses: tj-actions/changed-files@v46
        with:
          files: |
            **/*.sql
            **/*.yml
            **/*.csv
          include_removed: true
          include_renamed: true
          separator: ","

      - name: Find dbt_project.yml
        id: find_dbt_project
        working-directory: ${{ github.workspace }}
        run: |
          FILES="${{ steps.changes.outputs.all_changed_files }}"
          NEAREST_PROJECT=""
          if [ -z "$FILES" ]; then
            if [ -f "dbt_project.yml" ]; then NEAREST_PROJECT="dbt_project.yml"; fi
          else
            IFS=',' read -ra FILE_ARRAY <<< "$FILES"
            for file in "${FILE_ARRAY[@]}"; do
              [ -z "$file" ] && continue
              DIR=$(dirname "$file")
              while true; do
                if [ -f "$DIR/dbt_project.yml" ]; then NEAREST_PROJECT="$DIR/dbt_project.yml"; break 2; fi
                if [ "$DIR" = "." ]; then
                  if [ -f "dbt_project.yml" ]; then NEAREST_PROJECT="dbt_project.yml"; fi
                  break
                fi
                DIR=$(dirname "$DIR")
              done
            done
          fi
          if [ -n "$NEAREST_PROJECT" ]; then
            echo "dbt_project_path=$NEAREST_PROJECT" >> $GITHUB_OUTPUT
          else
            echo "dbt_project_path=" >> $GITHUB_OUTPUT
          fi

      - name: Run PR impact analysis via Prizm API
        id: impact-analysis
        env:
          GITHUB_REPO: ${{ github.repository }}
          PR_NUMBER: ${{ github.event.pull_request.number }}
          GITHUB_TOKEN: ${{ secrets.TOKEN }}
          DBT_MCP_BASE_URL: ${{ vars.DBT_MCP_BASE_URL }}
          CLIENT_LINK_URL: ${{ vars.CLIENT_LINK_URL }}
          CHANGED_FILES: ${{ steps.changes.outputs.all_changed_files }},${{ steps.changes.outputs.deleted_files }}
          PRIZM_TOKEN: ${{ secrets.PRIZM_TOKEN }}
          DBT_PROJECT_FILE: ${{ steps.find_dbt_project.outputs.dbt_project_path }}
          DBT_ENVIRONMENTS: 'DBT Core Connection'
        run: |
          URL="${DBT_MCP_BASE_URL}/api/v1/dbt/github/pr-impact-analysis"
          DBT_PROJECT_CONTENT="null"
          if [ -n "$DBT_PROJECT_FILE" ] && [ -f "$DBT_PROJECT_FILE" ]; then
            DBT_PROJECT_CONTENT=$(jq -Rs . < "$DBT_PROJECT_FILE")
          fi
          PAYLOAD=$(cat <<EOF
          {
            "repo": "$GITHUB_REPO",
            "pr_number": "$PR_NUMBER",
            "github_token": "$GITHUB_TOKEN",
            "changed_files_list": "$CHANGED_FILES",
            "dbt_environments": "DBT Core Connection",
            "client_link_url": "$CLIENT_LINK_URL",
            "dbt_project_file_content": $DBT_PROJECT_CONTENT
          }
          EOF
          )
          RESPONSE=$(curl -s -X POST "$URL" \
            -H "Content-Type: application/json" \
            -H "Authorization: Bearer ${PRIZM_TOKEN}" \
            -d "$PAYLOAD")
          echo "response<<EOF" >> $GITHUB_OUTPUT
          echo "$RESPONSE" >> $GITHUB_OUTPUT
          echo "EOF" >> $GITHUB_OUTPUT
```

***

## Step 4: Verify

Open a pull request that modifies any `.sql`, `.yml`, or `.csv` file in the repository. The workflow runs automatically and adds an impact analysis comment to the PR. On subsequent pushes to the same PR, the comment is updated in place.

If the action runs but no assets appear in the comment, confirm that the modified models exist in Prizm's lineage graph and that the `DBT_ENVIRONMENTS` value matches a configured dbt environment name in Prizm.

***

## Configuration reference

| Input                                    | Required | Description                                                                                                                                                |
| ---------------------------------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `GITHUB_TOKEN` (secret: `TOKEN`)         | Yes      | PAT with pull request write permissions — used to post and update the impact comment.                                                                      |
| `DBT_MCP_BASE_URL` (variable)            | Yes      | Prizm tenant URL — used for API requests.                                                                                                                  |
| `PRIZM_TOKEN` (secret)                   | Yes      | Prizm API token — authenticates the impact analysis call.                                                                                                  |
| `CLIENT_LINK_URL` (variable)             | Yes      | Prizm tenant URL — used to build asset links in the PR comment.                                                                                            |
| `DBT_ENVIRONMENTS` (env var in workflow) | No       | dbt environment name in Prizm to use for lineage. Defaults to `'DBT Core Connection'`. Set to map a branch to a specific environment (e.g., `'dev,prod'`). |
