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: CI and Deploy to GKE | |
on: | |
push: | |
branches: | |
- deployment-ci | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up GCP credentials | |
uses: google-github-actions/setup-gcloud@v0.2.1 | |
with: | |
service_account_key: ${{ secrets.GCP_SA_KEY }} | |
project_id: ${{ secrets.GCP_PROJECT_ID }} | |
- name: Set up GKE | |
uses: imjasonh/gke-auth@v0.1.0 | |
with: | |
project: ${{ secrets.GCP_PROJECT_ID }} | |
location: ${{ secrets.GKE_CLUSTER_LOCATION }} | |
cluster: ${{ secrets.GKE_CLUSTER_NAME }} | |
- name: Configure kubectl | |
run: | | |
mkdir -p $HOME/.kube | |
cp ./kubeconfig.yaml $HOME/.kube/config | |
kubectl config use-context ${{ secrets.GKE_CLUSTER_NAME }} | |
- name: Build Docker image | |
run: docker build -t your-backend-image:latest . | |
- name: Database Migrations | |
run: docker run --env-file=.env your-backend-image:latest npx prisma migrate dev --name init | |
- name: Deploy to GKE | |
run: kubectl apply -f k8s/deployment.yaml |