Skip to content

Update deployment.yaml #65

Update deployment.yaml

Update deployment.yaml #65

Workflow file for this run

name: Stage CI/CD Pipeline
on:
push:
branches: ['staging']
env:
PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
GAR_LOCATION: us-west1
GKE_CLUSTER: leap-stage
GKE_ZONE: us-west1
DEPLOYMENT_NAME: observatory-service-stage
IMAGE: observatory-service
REPOSITORY: backend
jobs:
setup-build-publish-deploy:
name: Setup, Build, Publish, and Deploy
runs-on: ubuntu-latest
environment: stage
permissions:
contents: 'read'
id-token: 'write'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Authenticate with Google Cloud
uses: google-github-actions/[email protected]
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: Configure Docker
run: gcloud auth configure-docker ${{ env.GAR_LOCATION }}-docker.pkg.dev
- name: Set up GKE credentials
uses: google-github-actions/get-gke-credentials@v2
with:
cluster_name: ${{ env.GKE_CLUSTER }}
location: ${{ env.GKE_ZONE }}
project_id: ${{ env.PROJECT_ID }}
- name: Build Docker image
run: docker build -t ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.IMAGE }}:$GITHUB_SHA .
- name: Push Docker image to Artifact Registry
run: docker push ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.IMAGE }}:$GITHUB_SHA
- name: Deploy to GKE (Staging)
run: |
cd k8s/staging
sed -i "s|gcr.io/PROJECT_ID/observatory-service:TAG|${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.IMAGE }}:$GITHUB_SHA|" deployment.yaml
kubectl apply -f configmap.yaml
kubectl apply -f deployment.yaml
kubectl apply -f service.yaml
kubectl rollout status deployment/$DEPLOYMENT_NAME
kubectl get services -o wide
- name: Deploy HPA
run: kubectl apply -f k8s/staging/hpa.yaml