Skip to content

Updated CI/CD Pipeline #46

Updated CI/CD Pipeline

Updated CI/CD Pipeline #46

Workflow file for this run

name: Backend CI - Test, Build and Push Images

Check failure on line 1 in .github/workflows/backend_ci.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/backend_ci.yml

Invalid workflow file

(Line: 55, Col: 9): Unexpected value 'secrets'
on:
workflow_dispatch:
push:
branches:
- development
- main
paths:
- 'backend/**'
- '.github/workflows/backend_ci.yml'
pull_request:
branches:
- main
paths:
- 'backend/**'
- '.github/workflows/backend_ci.yml'
jobs:
build_and_push_backend:
runs-on: ubuntu-latest
# ... (Add steps for Checkout, Azure Login, Build/Push Backend Images here) ...
# Ensure this job builds the Product and Order service images.
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to Azure
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Build and Push Backend Images
run: |
az acr login --name ${{ secrets.AZURE_CONTAINER_REGISTRY }}
docker build -t ${{ secrets.AZURE_CONTAINER_REGISTRY }}/product-api:latest ./backend/product-api
docker push ${{ secrets.AZURE_CONTAINER_REGISTRY }}/product-api:latest
docker build -t ${{ secrets.AZURE_CONTAINER_REGISTRY }}/order-api:latest ./backend/order-api
docker push ${{ secrets.AZURE_CONTAINER_REGISTRY }}/order-api:latest
# Linkage Job: Calls the Backend CD workflow
trigger_backend_cd:
runs-on: ubuntu-latest
needs: build_and_push_backend
# CRITICAL: Only trigger CD when pushing to 'main'
if: github.ref == 'refs/heads/main'
steps:
- name: "Call Backend CD Workflow"
uses: ./.github/workflows/backend-cd.yml
with:
# Pass required cluster details
aks_cluster_name: YOUR_CLUSTER_NAME
aks_resource_group: YOUR_RESOURCE_GROUP
aks_acr_name: YOUR_ACR_NAME
secrets:
azure_credentials: ${{ secrets.AZURE_CREDENTIALS }}