-
Notifications
You must be signed in to change notification settings - Fork 1
71 lines (61 loc) · 2.52 KB
/
cd.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
name: CD
on:
push:
branches:
- main
env:
REGISTRY: ghcr.io
IMAGE_NAME: basedosdados/queries-basedosdados-dev/dbt-rpc
jobs:
build-container:
name: Build, publish and register
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Import Secrets
id: import_secrets
uses: hashicorp/[email protected]
with:
url: https://vault.basedosdados.org
token: ${{ secrets.VAULT_TOKEN }}
secrets: |
secret/data/gcp_credentials/basedosdados-dev GCP_SA_KEY_BASE64 | GCP_SA_KEY_BASE64 ;
secret/data/gcp_credentials/basedosdados-dev GCP_PROJECT_ID | GCP_PROJECT_ID ;
secret/data/gcp_credentials/basedosdados-dev GKE_CLUSTER_NAME | GKE_CLUSTER_NAME ;
secret/data/gcp_credentials/basedosdados-dev GKE_CLUSTER_ZONE | GKE_CLUSTER_ZONE ;
- name: Setup Google Cloud CLI
uses: google-github-actions/[email protected]
with:
service_account_key: ${{ steps.import_secrets.outputs.GCP_SA_KEY_BASE64 }}
project_id: ${{ steps.import_secrets.outputs.GKE_PROJECT_ID }}
export_default_credentials: true
- name: Get GKE credentials
uses: google-github-actions/[email protected]
with:
cluster_name: ${{ steps.import_secrets.outputs.GKE_CLUSTER_NAME }}
location: ${{ steps.import_secrets.outputs.GKE_CLUSTER_ZONE }}
credentials: ${{ steps.import_secrets.outputs.GCP_SA_KEY_BASE64 }}
- name: Log in to the Container registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY}}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/[email protected]
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}
- name: Set up Kustomize
run: |-
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: |-
./kustomize edit set image gcr.io/PROJECT_ID/IMAGE_DBT:TAG=$REGISTRY/$IMAGE_NAME:$GITHUB_SHA
./kustomize build . | kubectl apply -n prefect -f -
kubectl rollout status -w -n prefect deployment/dbt-rpc-dev
kubectl rollout status -w -n prefect deployment/dbt-rpc-prod