add AKS steps (#10) #5
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: CD | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout the repository | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
# Log in to Azure CLI | |
- name: Log in via Azure CLI | |
uses: azure/login@v1 | |
with: | |
creds: ${{ secrets.AZURE_CREDENTIALS }} | |
# Log in to Azure Container Registry | |
- name: Log in to Azure Container Registry | |
uses: azure/docker-login@v1 | |
with: | |
login-server: ${{ secrets.REGISTRY_LOGIN_SERVER }} | |
username: ${{ secrets.REGISTRY_USERNAME }} | |
password: ${{ secrets.REGISTRY_PASSWORD }} | |
# Build and push server image | |
- name: Build and push server image | |
run: | | |
docker build -t server:latest ./server | |
docker tag server:latest ${{ secrets.REGISTRY_LOGIN_SERVER }}/server:latest | |
docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/server:latest | |
# Build and push client image | |
- name: Build and push client image | |
run: | | |
docker build -t client:latest ./client | |
docker tag client:latest ${{ secrets.REGISTRY_LOGIN_SERVER }}/client:latest | |
docker push ${{ secrets.REGISTRY_LOGIN_SERVER }}/client:latest | |
# Set up kubectl (the Kubernetes CLI) | |
- name: Set up kubectl | |
uses: azure/setup-kubectl@v3 | |
with: | |
version: 'latest' | |
# Set up AKS credentials | |
- name: Get AKS credentials | |
run: | | |
az aks get-credentials --resource-group ${{ secrets.AKS_RESOURCE_GROUP }} --name ${{ secrets.AKS_CLUSTER_NAME }} | |
# Deploy server to AKS | |
- name: Deploy server to AKS | |
run: | | |
kubectl set image deployment/server-deployment server=${{ secrets.REGISTRY_LOGIN_SERVER }}/server:latest | |
kubectl rollout status deployment/server-deployment | |
# Deploy client to AKS | |
- name: Deploy client to AKS | |
run: | | |
kubectl set image deployment/client-deployment client=${{ secrets.REGISTRY_LOGIN_SERVER }}/client:latest | |
kubectl rollout status deployment/client-deployment |