-
Notifications
You must be signed in to change notification settings - Fork 5
88 lines (71 loc) · 2.81 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: Generate Docs on merge to Main
on: # yamllint disable-line rule:truthy
push:
branches:
- main
paths:
- automate/*
- transform/*
- transform/**/*
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
build:
name: Deployment Script
runs-on: ubuntu-latest
# dbt 1.6 image
container: datacoves/pi7-ci-basic-base:1.9.202309122155-20230923154521
defaults:
run:
working-directory: /__w/balboa/balboa/transform
env:
DBT_PROFILES_DIR: /__w/balboa/balboa/automate/dbt
DATACOVES__DBT_HOME: /__w/balboa/balboa/transform
DATACOVES__MAIN__ACCOUNT: ${{ secrets.DATACOVES__MAIN__ACCOUNT }}
DATACOVES__MAIN__ROLE: ${{ secrets.DATACOVES__MAIN__ROLE }}
DATACOVES__MAIN__WAREHOUSE: ${{ secrets.DATACOVES__MAIN__WAREHOUSE }}
DATACOVES__MAIN__DATABASE: BALBOA
DATACOVES__STAGING__DATABASE: BALBOA_STAGING
DATACOVES__MAIN__USER: ${{ secrets.DATACOVES__MAIN__USER }}
DATACOVES__MAIN__PASSWORD: ${{ secrets.DATACOVES__MAIN__PASSWORD }}
steps:
- name: Checkout branch
uses: actions/checkout@v2
with:
ref: ${{ github.event.push.head.sha }}
fetch-depth: 0
- name: Set Secure Directory
run: git config --global --add safe.directory /__w/balboa/balboa
- name: Install dbt packages
run: "dbt deps"
- name: Get prod manifest
id: prod-manifest
run: "../automate/dbt/get_artifacts.sh"
- name: Generate dbt documentation
run: "dbt docs generate"
- name: Run blue / green deployment
id: run-blue-green
env:
MANIFEST_FOUND: ${{ steps.prod-manifest.outputs.manifest_found }}
run: "../automate/blue_green_run.py --ci-cd-run -t prd"
- name: Drop relations in db that are no longer in dbt
run: "dbt run-operation drop_orphanate_relations --args '{\"dry_run\": false}'"
- name: Delete merged test databases
run: "../automate/dbt/remove_test_databases.sh"
- name: Deploy docs 🚀
uses: JamesIves/github-pages-deploy-action@4.1.4
with:
branch: dbt-docs
folder: transform/target
- uses: fregante/setup-git-user@v2
- name: Bump dbt project and git project version
run: "../automate/dbt/bump_dbt_project.sh"
- name: Push version changes
uses: ad-m/github-push-action@v0.6.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref_name }}
tags: true
- name: Drop staging db on Failure
if: always() && (steps.run-blue-green.outcome == 'failure')
run: "dbt --no-write-json run-operation drop_staging_db --args 'db_name: ${{env.DATACOVES__STAGING__DATABASE}}'" # yamllint disable-line rule:line-length