adding new zoneamento (#77) #173
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CD | |
on: | |
push: | |
branches: | |
- master | |
env: | |
GCP_PROJECT_ID: ${{ secrets.GKE_PROJECT }} | |
GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }} | |
GH_PAT: ${{ secrets.GH_PAT }} | |
GKE_CLUSTER: ${{ secrets.GKE_CLUSTER_NAME }} | |
GKE_ZONE: ${{ secrets.GKE_CLUSTER_ZONE }} | |
IMAGE_NAME: ghcr.io/prefeitura-rio/dbt-rpc | |
jobs: | |
build-container: | |
name: Build, publish and register | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.x | |
- name: Create credentials directory | |
run: mkdir -p credentials | |
- name: Mount credentials | |
env: | |
DBT_CREDENTIALS_DEV: ${{ secrets.DBT_CREDENTIALS_DEV }} | |
run: echo "$DBT_CREDENTIALS_DEV" > credentials/dev.json | |
- name: Install dbt | |
run: pip install dbt-core dbt-bigquery setuptools | |
- name: Compile dbt models | |
run: dbt compile --profiles-dir . --profile default --target compile | |
- name: Setup Google Cloud CLI | |
uses: google-github-actions/[email protected] | |
with: | |
service_account_key: ${{ secrets.GKE_SA_KEY }} | |
project_id: ${{ secrets.GKE_PROJECT }} | |
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 }} | |
- name: Build and publish image | |
run: | | |
docker build -t $IMAGE_NAME:$GITHUB_SHA . | |
echo $GH_PAT | docker login ghcr.io -u gabriel-milan --password-stdin | |
docker push $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=$IMAGE_NAME:$GITHUB_SHA | |
./kustomize build . | kubectl apply -n prefect-agent-datario -f - | |
./kustomize build . | kubectl apply -n prefect-agent-datario-dev -f - | |
kubectl rollout status -w -n prefect-agent-datario deployment/dbt-rpc-dev | |
kubectl rollout status -w -n prefect-agent-datario deployment/dbt-rpc-prod | |
kubectl rollout status -w -n prefect-agent-datario-dev deployment/dbt-rpc-dev | |
kubectl rollout status -w -n prefect-agent-datario-dev deployment/dbt-rpc-prod |