-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (70 loc) · 2.39 KB
/
cd-docs.yaml
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
name: CD-docs
on:
pull_request:
branches:
- main
push:
branches:
- main
env:
GKE_PROJECT_ID: ${{ secrets.GKE_PROJECT_ID }}
GKE_SA_KEY: ${{ secrets.GKE_SA_KEY }}
GKE_CLUSTER: ${{ secrets.GKE_APP_CLUSTER_NAME }}
GKE_ZONE: ${{ secrets.GKE_CLUSTER_ZONE }}
IMAGE_NAME: gcr.io/rj-smtr/dbt-docs
DBT_USER: ${{ github.actor }}
jobs:
build-container:
name: Build and publish docs
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Python version
uses: actions/setup-python@v2
with:
python-version: "3.9"
- run: |-
pip install --no-cache-dir -r requirements.txt
# Setup gcloud CLI
- name: Setup Google Cloud CLI
uses: google-github-actions/[email protected]
with:
service_account_key: ${{ secrets.GKE_SA_KEY }}
project_id: ${{ secrets.GKE_PROJECT_ID}}
export_default_credentials: true
- name: Get GKE credentials
uses: google-github-actions/[email protected]
with:
cluster_name: ${{ env.GKE_CLUSTER }}
location: ${{ env.GKE_ZONE }}
credentials: ${{ secrets.GKE_SA_KEY }}
# Configure Docker to use the gcloud command-line tool as a credential
# helper for authentication
- name: Configure Docker Registry Auth
run: |-
gcloud --quiet auth configure-docker
- name: Install DBT dependencies
run: dbt deps
- name: Generate Docs Static Files
run: |
cd queries
sh ./.kubernetes/docs/generate-docs.sh $KEY
env:
KEY: ${{ secrets.GKE_SA_KEY }}
- name: Build and publish image
run: |
cd queries
docker build -t $IMAGE_NAME:$GITHUB_SHA . -f Dockerfile-docs
docker push $IMAGE_NAME:$GITHUB_SHA
- name: Set up Kustomize
run: |-
cd queries/.kubernetes/docs
curl -sfLo kustomize https://github.com/kubernetes-sigs/kustomize/releases/download/v3.1.0/kustomize_3.1.0_linux_amd64
chmod u+x ./kustomize
- name: Deploy
run: |-
cd queries/.kubernetes/docs
./kustomize edit set image gcr.io/PROJECT_ID/IMAGE_DBT:TAG=$IMAGE_NAME:$GITHUB_SHA
./kustomize build . | kubectl apply -n dbt-docs -f -
kubectl rollout status -w -n dbt-docs deployment/dbt-docs