Skip to content

CUDA Build

CUDA Build #86

Workflow file for this run

name: CUDA Build
on:
workflow_dispatch: # Manually trigger the workflow
#on:
# push:
# branches:
# - main
# pull_request:
# branches:
# - main
permissions:
id-token: write
contents: read
jobs:
build:
runs-on: ubuntu-latest
#services:
#nn_backend:
# image: nvidia/cuda:12.3.2-devel-ubuntu22.04
# ports:
# - "8080:8080"
# options: --privileged # Required for GPU access
# env:
# NVIDIA_VISIBLE_DEVICES: all
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Azure Login
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Login to Azure Container Registry
uses: azure/docker-login@v1
with:
login-server: test1repo.azurecr.io
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}
# - name: Build and deploy nn_backend
# run: |
# docker build ./NN_backend -t test1repo.azurecr.io/nn_backend:${GITHUB_RUN_NUMBER}
# docker push test1repo.azurecr.io/nn_backend:${GITHUB_RUN_NUMBER}
- name: Build and deploy react_app
run: |
docker build ./react_app -t test1repo.azurecr.io/react_app:${GITHUB_RUN_NUMBER}
docker push test1repo.azurecr.io/react_app:${GITHUB_RUN_NUMBER}
- id: check-aks
name: Check if AKS Cluster exists
uses: azure/CLI@v2
with:
azcliversion: latest
inlineScript: |
set -x
result=$(az aks show --resource-group my_test --name myAKSCluster 2>/dev/null | jq -r '.id')
exit_code=$?
if [ $exit_code -ne 0 ]; then
echo "Error executing az aks show command. Exit code: $exit_code"
echo "Error message: $result"
echo "::error::Error executing az aks show command. Exit code: $exit_code"
exit $exit_code
fi
if [[ -z "$result" || "$result" == *"ResourceNotFound"* ]]; then
echo "cluster_exists=false" >> $GITHUB_OUTPUT
else
echo "cluster_exists=true" >> $GITHUB_OUTPUT
fi
- name: Print name
run: |
if [ "${{steps.check-aks.outputs.cluster_exists}}" != "true" ]; then
echo "checking value ${{steps.check-aks.outputs.cluster_exists}}"
else
echo "heyyyy"
fi
- name: Create AKS Cluster
uses: azure/CLI@v2
with:
azcliversion: latest
inlineScript: |
if [ "${{steps.check-aks.outputs.cluster_exists}}" != "true" ]; then
az aks create --resource-group my_test --name myAKSCluster --node-count 1 --generate-ssh-keys
else
echo "AKS cluster is present"
ls
pwd
fi
- name: Get AKS Credentials
uses: azure/CLI@v2
with:
azcliversion: latest
inlineScript: |
if [ "${{steps.check-aks.outputs.cluster_exists}}" != "true" ]; then
AKS_ID=$(az aks show --resource-group my_test --name myAKSCluster --query id -o tsv)
az role assignment create --role "AcrPull" --assignee ${{ secrets.AZURE_CLIENT_ID }} --scope $AKS_ID
az aks update --resource-group my_test --name myAKSCluster --attach-acr test1repo
fi
az account set --subscription ${{ secrets.AZURE_SUBSCRIPTION_ID }}
az aks get-credentials --resource-group my_test --name myAKSCluster --overwrite-existing
- uses: azure/setup-kubectl@v3
- uses: azure/[email protected]
with:
resource-group: my_test
cluster-name: myAKSCluster
- name: Replace placeholders in Kubernetes YAML files
run: |
cd k8s
sed -i "s|image: test1repo.azurecr.io/react_app:\$imageTag|image: test1repo.azurecr.io/react_app:${GITHUB_RUN_NUMBER}|" react_app_Deployment.yaml
# kubectl set image -f deployment.template.yml react-app=test1repo.azurecr.io/react_app:$imageTag --local -o yaml > react_app_Deployment.yaml
# sed -i 's|${{ github.run_number }}|'"$GITHUB_RUN_NUMBER"'|g' react_app_Deployment.yaml
# echo "github.run_number ${{ github.run_number }} "
- name: Deploy to AKS
run: |
cd k8s
kubectl apply -f react_app_Deployment.yaml -f react_app_Service.yaml