diff --git a/.github/workflows/deploytoAksCluster.yml b/.github/workflows/deploytoAksCluster.yml new file mode 100644 index 00000000..e7079166 --- /dev/null +++ b/.github/workflows/deploytoAksCluster.yml @@ -0,0 +1,50 @@ +on: [push] +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + + - uses: azure/docker-login@v1 + with: + login-server: ddccsrv.azurecr.io + username: ${{ secrets.acr_ddccsrv_username }} + password: ${{ secrets.acr_ddccsrv_password }} + + - name: Build and push image to ACR + id: build-image + run: | + docker build "$GITHUB_WORKSPACE/" -f "Dockerfile" -t ddccsrv.azurecr.io/ddccservices:${{ github.sha }} --label dockerfile-path=Dockerfile + docker push ddccsrv.azurecr.io/ddccservices:${{ github.sha }} + + - uses: azure/k8s-set-context@v1 + with: + kubeconfig: ${{ secrets.aks_ddccservices_kubeConfig }} + id: login + + - name: Create namespace + run: | + namespacePresent=`kubectl get namespace | grep default | wc -l` + if [ $namespacePresent -eq 0 ] + then + echo `kubectl create namespace default` + fi + + - uses: azure/k8s-create-secret@v1 + with: + namespace: default + container-registry-url: ddccsrv.azurecr.io + container-registry-username: ${{ secrets.acr_ddccsrv_username }} + container-registry-password: ${{ secrets.acr_ddccsrv_password }} + secret-name: ddccservicesdockerauth + + - uses: azure/k8s-deploy@v1.2 + with: + namespace: default + manifests: | + manifests/deployment.yml + manifests/service.yml + images: | + ddccsrv.azurecr.io/ddccservices:${{ github.sha }} + imagepullsecrets: | + ddccservicesdockerauth