-
Notifications
You must be signed in to change notification settings - Fork 6
82 lines (68 loc) · 2.66 KB
/
cd_erd_diagram.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
name: Publish ERD diagram
on:
push:
branches:
- prd
workflow_dispatch:
env:
DBT_DATASET: "prd"
DBT_PROFILES_DIR: "."
POETRY_VERSION: "2.0.1"
jobs:
publish-erd-diagram:
name: Publish ERD diagram
permissions:
contents: write
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
id: setup-python
- name: Load cached Poetry installation
id: cached-poetry
uses: actions/cache@v4
with:
path: /home/runner/.local
key: poetry-cache-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ env.POETRY_VERSION }}
- name: Install Poetry
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
installer-parallel: true
version: ${{ env.POETRY_VERSION }}
virtualenvs-create: true
virtualenvs-in-project: true
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v2'
- name: Save prd GCP credentials to runner
run: |
echo "${{ secrets.DBT_CICD_SA_SECRET_KEY_PRD_BASE64_ENCODED }}" | base64 --decode >> ./service_account.json && \
export GOOGLE_APPLICATION_CREDENTIALS="$(pwd)/service_account.json"
- name: Authenticate with GCP
run: |
gcloud auth activate-service-account [email protected] --key-file=./service_account.json && \
gcloud config set project beyond-basics-prd
- name: Load cached venv
id: cached-poetry-dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install python packages
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-ansi
- name: Generate dbt docs
run: |
poetry run dbt deps --target prd
poetry run dbt docs generate --target prd
- name: Generate ERD diagram
run: poetry run python ./scripts/generate_marts_erd_diagram.py
- name: Commit and push ERD
run: |
git config user.name "github-actions"
git config user.email "[email protected]"
git fetch
git checkout erd-diagram
git add -f ./target/mermaid.png
git commit -m "Adding ERD diagram" --allow-empty
git push -f origin erd-diagram