Skip to content

Merge branch 'main' of github.com:johnbedeir/End-to-End-DevOps-GCP-PH… #7

Merge branch 'main' of github.com:johnbedeir/End-to-End-DevOps-GCP-PH…

Merge branch 'main' of github.com:johnbedeir/End-to-End-DevOps-GCP-PH… #7

name: Continuous Deployment
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
# Check if the CI workflow was successful
if: github.event.workflow_run.conclusion == 'success'
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GCP_CREDENTIALS }}
- name: Set up Kubectl
uses: azure/setup-kubectl@v1
with:
version: 'latest'
- name: Install Google Cloud SDK and gke-gcloud-auth-plugin
run: |
sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates gnupg
echo "deb https://packages.cloud.google.com/apt cloud-sdk main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
sudo apt-get update && sudo apt-get install -y google-cloud-sdk google-cloud-cli-gke-gcloud-auth-plugin
- name: Configure kubectl to use the gke-gcloud-auth-plugin
run: |
echo "export USE_GKE_GCLOUD_AUTH_PLUGIN=True" >> $GITHUB_ENV
- name: Authenticate kubectl with GKE
run: |
gcloud container clusters get-credentials ${{ secrets.CLUSTER_NAME }} --zone ${{ secrets.ZONE }} --project ${{ secrets.GCP_PROJECT }}
- name: Verify kubectl
run: |
kubectl version --client
- name: Deploy to Kubernetes
run: |
kubectl apply -f k8s/ingress