Skip to content

Commit

Permalink
quick update flow
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuldeep-knoldus committed Jun 24, 2024
1 parent 0d81ccf commit 2229982
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions .github/workflows/gcp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ on:
branches:
- '**'

env:
PROJECT_ID: '${{ secrets.GKE_PROJECT }}'
SERVICE_ACCOUNT_KEY: '${{ secrets.SERVICE_ACCOUNT_KEY }}'
CLUSTER_NAME: blog-analyzer-cluster
REGION: '${{ secrets.GKE_ZONE }}'
REGISTRY_NAME: blog-analyzer

jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -78,7 +85,7 @@ jobs:
- name: Set up Google Cloud SDK
uses: google-github-actions/setup-gcloud@v1
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
project_id: ${{ secrets.PROJECT_ID }}
service_account_key: ${{ secrets.SERVICE_ACCOUNT_KEY }}

- name: Configure Docker for Google Container Registry
Expand All @@ -90,15 +97,14 @@ jobs:
echo "Service Names: $SERVICE_NAMES"
for SERVICE_NAME in $(echo $SERVICE_NAMES | tr ',' ' '); do
echo "Building and pushing Docker image for $SERVICE_NAME"
if [ -d "$SERVICE_NAME" ]; then
cd $SERVICE_NAME
if [ "$SERVICE_NAME" != "blogs-analyzer-ui" ]; then
IMAGE_NAME=gcr.io/${{ secrets.GCP_PROJECT_ID }}/$SERVICE_NAME:latest
IMAGE_NAME=gcr.io/${{ secrets.PROJECT_ID }}/$SERVICE_NAME:latest
docker build -t $IMAGE_NAME .
docker push $IMAGE_NAME
else
IMAGE_NAME=gcr.io/${{ secrets.GCP_PROJECT_ID }}/blogs-analyzer-ui:latest
IMAGE_NAME=gcr.io/${{ secrets.PROJECT_ID }}/blogs-analyzer-ui:latest
docker build -t $IMAGE_NAME .
docker push $IMAGE_NAME
fi
Expand All @@ -107,22 +113,18 @@ jobs:
done
- name: Deploy to GKE
env:
KUBECONFIG: ${{ secrets.KUBECONFIG }}
run: |
gcloud container clusters get-credentials ${{ secrets.GKE_CLUSTER_NAME }} --zone ${{ secrets.GKE_ZONE }}
gcloud container clusters get-credentials ${{ secrets.CLUSTER_NAME }} --zone ${{ secrets.GKE_ZONE }}
SERVICE_NAMES=$(cat projects-changes-deploy.txt)
echo "Service Names: $SERVICE_NAMES"
for SERVICE_NAME in $(echo $SERVICE_NAMES | tr ',' ' '); do
echo "Deploying $SERVICE_NAME to GKE"
if [ -d "$SERVICE_NAME" ]; then
cd $SERVICE_NAME/k8s
kubectl apply -f .
cd ../..
fi
done

sonarcloud:
name: SonarCloud Analysis
Expand Down

0 comments on commit 2229982

Please sign in to comment.