diff --git a/.github/workflows/backend-cd.yml b/.github/workflows/backend-cd.yml index 6035ed15..e1545c98 100644 --- a/.github/workflows/backend-cd.yml +++ b/.github/workflows/backend-cd.yml @@ -5,20 +5,30 @@ on: inputs: aks_cluster_name: description: 'Name of the AKS Cluster to deploy to' - required: true + required: false default: '' aks_resource_group: description: 'Resource Group of the AKS Cluster' - required: true + required: false default: '' aks_acr_name: description: 'Name of ACR' - required: true + required: false default: '' +################################################################################ + workflow_run: + workflows: ["Backend CI - Test, Build and Push Images to ACR"] + + + types: [completed] + jobs: deploy_backend: runs-on: ubuntu-latest + + if: ${{ github.event_name == 'workflow_dispatch' || (github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main') }} + environment: Production outputs: @@ -37,11 +47,14 @@ jobs: - name: Set Kubernetes context (get AKS credentials) run: | - az aks get-credentials --resource-group ${{ github.event.inputs.aks_resource_group }} --name ${{ github.event.inputs.aks_cluster_name }} --overwrite-existing + + + az aks get-credentials --resource-group "${{ vars.AKS_RESOURCE_GROUP }}" --name "${{ vars.AKS_CLUSTER_NAME }}" --overwrite-existing - name: Attach ACR run: | - az aks update --name ${{ github.event.inputs.aks_cluster_name }} --resource-group ${{ github.event.inputs.aks_resource_group }} --attach-acr ${{ github.event.inputs.aks_acr_name }} + az aks update --name "${{ vars.AKS_CLUSTER_NAME }}" --resource-group "${{ vars.AKS_RESOURCE_GROUP }}" --attach-acr "${{ vars.ACR_NAME }}" + - name: Deploy Backend Infrastructure (Namespace, ConfigMaps, Secrets, Databases) run: | @@ -99,3 +112,5 @@ jobs: - name: Logout from Azure run: az logout + + #Adding a line to trigger the code... diff --git a/.github/workflows/frontend_ci.yml b/.github/workflows/frontend_ci.yml index 9f9e76d9..5f1d0896 100644 --- a/.github/workflows/frontend_ci.yml +++ b/.github/workflows/frontend_ci.yml @@ -13,6 +13,9 @@ on: paths: # Only trigger if changes are in the frontend directory - 'frontend/**' - '.github/workflows/frontend_ci.yml' # Trigger if this workflow file changes + workflow_run: + workflows: ["CD - Deploy Backend Services to AKS"] + types: [completed] # Define global environment variables that can be used across jobs env: @@ -26,6 +29,8 @@ env: jobs: build_and_push_frontend: runs-on: ubuntu-latest + if: ${{ github.event_name == 'workflow_dispatch' || github.event_name == 'push' || (github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.head_branch == 'main') }} + steps: - name: Checkout repository diff --git a/README.md b/README.md index 23009398..81245d6b 100644 --- a/README.md +++ b/README.md @@ -36,3 +36,6 @@ image: .azurecr.io/: ### 2. Update Backend Pipeline (`.github/workflows/backend-cd.yml`) & Frontend Pipeline (`.github/workflows/frontend-cd.yml`) Ensure you replace all placeholders value to actual values. + + +# Adding a line to trigger the code... diff --git a/k8s/frontend.yaml b/k8s/frontend.yaml index 1948536d..4a23411b 100644 --- a/k8s/frontend.yaml +++ b/k8s/frontend.yaml @@ -18,7 +18,7 @@ spec: spec: containers: - name: frontend-container - image: durgeshsamariya.azurecr.io/frontend:latest + image: soorajw9cacr.azurecr.io/frontend:latest imagePullPolicy: Always ports: - containerPort: 80 diff --git a/k8s/order-service.yaml b/k8s/order-service.yaml index c9d92e4d..58b7bef7 100644 --- a/k8s/order-service.yaml +++ b/k8s/order-service.yaml @@ -18,7 +18,7 @@ spec: spec: containers: - name: order-service-container - image: durgeshsamariya.azurecr.io/order_service:latest + image: soorajw9cacr.azurecr.io/order_service:latest imagePullPolicy: Always ports: - containerPort: 8000 diff --git a/k8s/product-service.yaml b/k8s/product-service.yaml index 0cbbd505..984094d7 100644 --- a/k8s/product-service.yaml +++ b/k8s/product-service.yaml @@ -18,7 +18,7 @@ spec: spec: containers: - name: product-service-container - image: durgeshsamariya.azurecr.io/product_service:latest + image: soorajw9cacr.azurecr.io/product_service:latest imagePullPolicy: Always ports: - containerPort: 8000 diff --git a/k8s/secrets.yaml b/k8s/secrets.yaml index 5eebe1fa..533f25dd 100644 --- a/k8s/secrets.yaml +++ b/k8s/secrets.yaml @@ -13,6 +13,6 @@ data: # Azure Storage Account Credentials for Product Service image uploads # REPLACE WITH YOUR ACTUAL BASE64 ENCODED VALUES from your Azure Storage Account # Example: echo -n 'myblobstorageaccount' | base64 - AZURE_STORAGE_ACCOUNT_NAME: "ZHVyZ2VzaHNhbWFyaXlh" - # Example: echo -n 'your_storage_account_key_string' | base64 - AZURE_STORAGE_ACCOUNT_KEY: "aEFNQ24rbkh2cmhwSGFEaW5jSnAxNFlHaU5nTnJja2NJR05Bc3Y5VXZPUlpsblJkbkVUR3drdTREdSszblBDR3E4ZEVTVjlFNE1jMytBU3RubmZ5QVE9PQ==" + AZURE_STORAGE_ACCOUNT_NAME: "c29vcmFqd2Vlazljc3RvcmFnZQ==" + # Example: echo -n 'your_storage_account_key_string' | base64 wq swq s + AZURE_STORAGE_ACCOUNT_KEY: "YXREN3MwRWF0TkFXbFk5ZUJkUFZqdnRYQzljS1dvZVlhN05HZkRZNkxGZjhpVDliS1g1c0g0RVBUZTVWcGovZGlLSDNPQ3JvWGtsRitBU3RlVWZaUGc9PQ=="