Update GCP_GKE.yml #15
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 service account key and save it | |
run: | | |
echo "${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}" | base64 --decode > $HOME/gcloud-service-key.json | |
shell: bash | |
- 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 |