best practices for keeping track dbt model versions for different environments

The problem I’m having

I am currently working on a project where we use dbt for our data transformations in PostgreSQL, and I am looking for best practices to keep track of the environments ~ we have more than 10 ~ and the specific code (e.g. dbt models) versions that have been deployed to each environment.

The context of why I’m trying to do this

I’m trying to do this to keep a track of list of environments with the respective version of my code

What I’ve already tried

I have tried using tags, storing and housekeeping deployment logs, and leveraging dbt artifacts but it would be helpful to read what has worked best for you.

Some example code

(Use-case) Use a GitLab wiki page for updating deployment logs


DEPLOY_TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")

current_content=$(curl --silent --header "PRIVATE-TOKEN: $API_TOKEN" \
  "$PROJECT_ID/wikis/$WIKI_PAGE_TITLE" | jq -r '.content')

new_content="$current_content\n\n## Deployment Logs\n- **Branch/Tag**: $MY_TAG\n- **Commit SHA**: $COMMIT_SHA\n- **Timestamp**: $DEPLOY_TIMESTAMP"

WIKI_PAGE_TITLE_F=$(echo -n "$WIKI_PAGE_TITLE" | jq -sRr @uri)

curl --request PUT --header "PRIVATE-TOKEN: $API_TOKEN" \
     --header "Content-Type: application/json" \
     --data "{\"content\":\"$new_content\"}" \