diff --git a/.github/workflows/staging-ci-cd.yml b/.github/workflows/staging-ci-cd.yml index ccc2d24e7f4f9766978055dd6e464be9416947cc..e69f52a2c002d4b0540629dd1cde4d21c725393c 100644 --- a/.github/workflows/staging-ci-cd.yml +++ b/.github/workflows/staging-ci-cd.yml @@ -40,16 +40,34 @@ jobs: uses: actions/checkout@v3 - name: Install the gcloud CLI - uses: google-github-actions/setup-gcloud@v0 + uses: google-github-actions/setup-gcloud@v2 with: project_id: ${{ secrets.GOOGLE_PROJECT }} service_account_key: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} export_default_credentials: true + - name: Authenticate with GCP + uses: google-github-actions/auth@v1 + with: + credentials_json: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} + - name: Build and Push Docker Image env: GOOGLE_PROJECT: ${{ secrets.GOOGLE_PROJECT }} run: | gcloud auth configure-docker us-central1-docker.pkg.dev - docker build -t us-central1-docker.pkg.dev/$GOOGLE_PROJECT/my-repository/authentication:latest . - docker push us-central1-docker.pkg.dev/$GOOGLE_PROJECT/my-repository/authentication:latest \ No newline at end of file + docker build -t us-central1-docker.pkg.dev/$GOOGLE_PROJECT/staging-repository/authentication:latest . + docker push us-central1-docker.pkg.dev/$GOOGLE_PROJECT/staging-repository/authentication:latest + + - name: Install required components + run: | + gcloud components update + gcloud components install gke-gcloud-auth-plugin + + - name: Deploy to GKE + env: + GOOGLE_PROJECT: ${{ secrets.GOOGLE_PROJECT }} + run: | + gcloud container clusters get-credentials safetypin-staging --region asia-southeast2 + sed -i "s/GOOGLE_PROJECT/$GOOGLE_PROJECT/g" resources.yaml + kubectl apply -f resources.yaml \ No newline at end of file