From 9a5541f16bd63e83a144c2e644b4ae9560498416 Mon Sep 17 00:00:00 2001 From: BushraS-Protean Date: Sun, 25 May 2025 10:04:01 +0530 Subject: [PATCH] Create deploy-to-gke-updated.yaml Adding build and Deploy logic in same code --- .github/workflows/deploy-to-gke-updated.yaml | 47 ++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/deploy-to-gke-updated.yaml diff --git a/.github/workflows/deploy-to-gke-updated.yaml b/.github/workflows/deploy-to-gke-updated.yaml new file mode 100644 index 0000000..58007f4 --- /dev/null +++ b/.github/workflows/deploy-to-gke-updated.yaml @@ -0,0 +1,47 @@ +name: CI/CD to GKE + +on: + push: + branches: + - beckn-onix-v1.0-develop + +jobs: + deploy: + name: Build and Deploy to GKE + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Authenticate to Google Cloud + uses: google-github-actions/auth@v2 + with: + credentials_json: '${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_JSON }}' + + - name: Set up gcloud CLI + uses: google-github-actions/setup-gcloud@v1 + with: + project_id: ${{ secrets.GCP_PROJECT }} + export_default_credentials: true + + - name: Configure Docker to use Artifact Registry + run: gcloud auth configure-docker ${{ secrets.GCP_REGION }}-docker.pkg.dev + + - name: Build Docker Image + run: | + IMAGE_NAME=${{ secrets.GCP_REGION }}-docker.pkg.dev/${{ secrets.GCP_PROJECT }}/${{ secrets.GCP_REPO }}/beckn-onix:${{ github.sha }} + docker build -t $IMAGE_NAME . + docker push $IMAGE_NAME + + - name: Get GKE Credentials + run: | + gcloud container clusters get-credentials ${{ secrets.GKE_CLUSTER }} \ + --zone ${{ secrets.GKE_ZONE }} \ + --project ${{ secrets.GCP_PROJECT }} + + - name: Deploy to GKE + run: | + IMAGE_NAME=${{ secrets.GCP_REGION }}-docker.pkg.dev/${{ secrets.GCP_PROJECT }}/${{ secrets.GCP_REPO }}/beckn-onix:${{ github.sha }} + kubectl set image deployment/${{ secrets.DEPLOYMENT_NAME }} ${{ secrets.DEPLOYMENT_NAME }}=$IMAGE_NAME + kubectl rollout status deployment/${{ secrets.DEPLOYMENT_NAME }}