Skip to content

Merge pull request #309 from basedosdados/staging/br_geobr_mapas #311

Merge pull request #309 from basedosdados/staging/br_geobr_mapas

Merge pull request #309 from basedosdados/staging/br_geobr_mapas #311

Workflow file for this run

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