Skip to content

Update GCP_GKE.yml

Update GCP_GKE.yml #12

Workflow file for this run

name: Deploy to GKE
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Google Cloud SDK
uses: google-github-actions/setup-gcloud@v1
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
export_default_credentials: true
- name: Decode and write service account key to file
run: |
echo "${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}" | base64 --decode > $HOME/gcloud-service-key.json
- name: Authenticate with Google Cloud
run: |
gcloud auth activate-service-account --key-file=$HOME/gcloud-service-key.json
gcloud config set project ${{ secrets.GCP_PROJECT_ID }}
- name: Install gke-gcloud-auth-plugin
run: |
sudo apt-get update
sudo apt-get install -y google-cloud-sdk-gke-gcloud-auth-plugin
- name: Configure Kubectl
run: |
gcloud container clusters get-credentials ${{ secrets.GKE_CLUSTER_NAME }} --zone ${{ secrets.GKE_ZONE }}
- name: Deploy to GKE
run: |
kubectl apply -f k8s/react-deployment.yaml