Commit 3d672ccb authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

feat(deploy): redesign deployment strategy

BREAKING CHANGE: $AUTODEPLOY_TO_PROD no longer supported (replaced by $DBT_PROD_DEPLOY_STRATEGY - see doc)
parent e598efac
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -119,6 +119,7 @@ Here are variables supported to configure the production environment:
| Name                     | description                            | default value     |
| ------------------------ | -------------------------------------- | ----------------- |
| `DBT_PROD_TARGET`        | dbt [target](https://docs.getdbt.com/reference/dbt-jinja-functions/target) for `production` env | _none_ (disabled) |
| `DBT_PROD_DEPLOY_STRATEGY`| Defines the deployment to production strategy. One of `manual` (i.e. _one-click_) or `auto`. | `manual` |


## Jobs
+7 −0
Original line number Diff line number Diff line
@@ -105,6 +105,13 @@
          "name": "DBT_PROD_TARGET",
          "description": "dbt [target](https://docs.getdbt.com/reference/dbt-jinja-functions/target) for `production` env ",
          "mandatory": true
        },
        {
          "name": "DBT_PROD_DEPLOY_STRATEGY",
          "description": "Defines the deployment to production strategy.",
          "type": "enum",
          "values": ["manual", "auto"],
          "default": "manual"
        }
      ]
    }
+4 −19
Original line number Diff line number Diff line
@@ -50,6 +50,8 @@ variables:
  DBT_PROJECT_DIR: "."
  DBT_PROFILES_DIR: "."

  # default: one-click deploy
  DBT_PROD_DEPLOY_STRATEGY: manual

  # default production ref name (pattern)
  PROD_REF: '/^(master|main)$/'
@@ -344,8 +346,6 @@ dbt-sqlfluff-lint:
      when: never
    - !reference [.test-policy, rules]



# compile job
.dbt-build:
  extends: .dbt-base
@@ -364,7 +364,6 @@ dbt-sqlfluff-lint:
        - ${DBT_PROJECT_DIR}/target/
        - ${DBT_PROJECT_DIR}/reports/dbt-coverage.native.json


dbt-build-review:
  extends: .dbt-build
  variables:
@@ -377,7 +376,6 @@ dbt-build-review:
    # only on non-production, non-integration branches, with $XXX_REVIEW_PROJECT set
    - if: '$DBT_REVIEW_TARGET && $CI_COMMIT_REF_NAME !~ $PROD_REF && $CI_COMMIT_REF_NAME !~ $INTEG_REF'


dbt-build-integration:
  extends: .dbt-build
  variables:
@@ -438,7 +436,6 @@ dbt-review:
    # only on non-production, non-integration branches, with $XXX_REVIEW_PROJECT set
    - if: '$DBT_REVIEW_TARGET && $CI_COMMIT_REF_NAME !~ $PROD_REF && $CI_COMMIT_REF_NAME !~ $INTEG_REF'


# deploy to integration env (only on develop branch)
dbt-integration:
  extends: .dbt-deploy
@@ -456,7 +453,6 @@ dbt-integration:
    # only on integration branch(es), with $XXX_INTEG_PROJECT set
    - if: '$DBT_INTEG_TARGET && $CI_COMMIT_REF_NAME =~ $INTEG_REF'


# deploy to staging env (only on master branch)
dbt-staging:
  extends: .dbt-deploy
@@ -474,7 +470,6 @@ dbt-staging:
    # only on production branch(es), with $XXX_STAGING_PROJECT set
    - if: '$DBT_STAGING_TARGET && $CI_COMMIT_REF_NAME =~ $PROD_REF'

# Deploy to production if on branch master and variable DBT_PROD_TARGET defined and AUTODEPLOY_TO_PROD is set
dbt-production:
  extends: .dbt-deploy
  stage: production
@@ -495,16 +490,6 @@ dbt-production:
    # exclude if $XXX_PROD_PROJECT not set
    - if: '$DBT_PROD_TARGET == null || $DBT_PROD_TARGET == ""'
      when: never
    # if $AUTODEPLOY_TO_PROD: auto
    - if: $AUTODEPLOY_TO_PROD
    # else if PUBLISH_ON_PROD enabled: auto (because the publish job was blocking)
    - if: '$PUBLISH_ON_PROD == "true" || $PUBLISH_ON_PROD == "yes"'
    # else: manual, blocking
    - if: $DBT_PROD_TARGET # useless test, just to prevent GitLab warning
    - if: '$DBT_PROD_DEPLOY_STRATEGY == "manual"'
      when: manual





    - if: '$DBT_PROD_DEPLOY_STRATEGY == "auto"'