Create deploy-to-gke-updated.yaml
Adding build and Deploy logic in same code
This commit is contained in:
47
.github/workflows/deploy-to-gke-updated.yaml
vendored
Normal file
47
.github/workflows/deploy-to-gke-updated.yaml
vendored
Normal file
@@ -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 }}
|
||||
Reference in New Issue
Block a user