File tree Expand file tree Collapse file tree 1 file changed +64
-0
lines changed
Expand file tree Collapse file tree 1 file changed +64
-0
lines changed Original file line number Diff line number Diff line change 1+ name : CI/CD to AKS
2+
3+ on :
4+ push :
5+ branches : [ main ]
6+ pull_request :
7+ branches : [ main ]
8+
9+ jobs :
10+ build :
11+ runs-on : ubuntu-latest
12+
13+ steps :
14+ - name : Checkout code
15+ uses : actions/checkout@v3
16+
17+ - name : Set up Docker Buildx
18+ uses : docker/setup-buildx-action@v3
19+
20+ - name : Log in to Azure
21+ uses : azure/login@v1
22+ with :
23+ creds : ${{ secrets.AZURE_CREDENTIALS }}
24+
25+ - name : Log in to ACR
26+ run : |
27+ az acr login --name ${{ secrets.ACR_NAME }}
28+
29+ - name : Build and Push Docker image
30+ uses : docker/build-push-action@v5
31+ with :
32+ context : .
33+ push : true
34+ tags : ${{ secrets.ACR_NAME }}.azurecr.io/${{ vars.DOCKER_IMAGE_NAME }}:${{ github.sha }}
35+
36+ - name : Run tests in container
37+ run : |
38+ docker run --rm ${{ secrets.ACR_NAME }}.azurecr.io/${{ vars.DOCKER_IMAGE_NAME }}:${{ github.sha }} pytest
39+
40+ deploy :
41+ needs : build
42+ runs-on : ubuntu-latest
43+
44+ steps :
45+ - name : Checkout code
46+ uses : actions/checkout@v3
47+
48+ - name : Azure Login
49+ uses : azure/login@v1
50+ with :
51+ creds : ${{ secrets.AZURE_CREDENTIALS }}
52+
53+ - name : Get AKS credentials
54+ run : |
55+ az aks get-credentials \
56+ --resource-group ${{ secrets.AKS_RESOURCE_GROUP }} \
57+ --name ${{ secrets.AKS_CLUSTER_NAME }} \
58+ --overwrite-existing
59+
60+ - name : Deploy to AKS
61+ run : |
62+ kubectl set image deployment/my-app-deployment \
63+ my-app=${{ secrets.ACR_NAME }}.azurecr.io/${{ vars.DOCKER_IMAGE_NAME }}:${{ github.sha }}
64+ kubectl rollout status deployment/my-app-deployment
You can’t perform that action at this time.
0 commit comments