Skip to content

Users Service CD Workflow #24

Users Service CD Workflow

Users Service CD Workflow #24

name: Users Service CD Workflow
on:
workflow_run:
workflows: ["Users Service CI Workflow"]
types:
- completed
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/users-service