Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/backend_ci.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
name: Backend CI - Test, Build and Push Images to ACR

on:
# Trigger on pull requests into development branch
# Trigger on pull requests into main branch
pull_request:
branches:
- development
- main
paths:
- 'backend/**'
- '.github/workflows/backend_ci.yml'

# Trigger on pushes to main branch
# Trigger on pushes to main or development branches
push:
branches:
- main
- development
paths:
- 'backend/**'
- '.github/workflows/backend_ci.yml'
Expand Down
56 changes: 34 additions & 22 deletions .github/workflows/frontend_ci.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,61 @@
# week08/.github/workflows/frontend_ci.yml

name: Frontend CI - Build & Push Image

on:
# Trigger on pull requests into development branch
# Trigger on pull requests into main branch
pull_request:
branches:
- development
- main
paths:
- 'frontend/**'
- '.github/workflows/frontend_ci.yml'

# Trigger on pushes to main branch
# Trigger on pushes to main or development branches
push:
branches:
- main
- development
paths:
- 'frontend/**'
- '.github/workflows/frontend_ci.yml'

# Manual trigger
workflow_dispatch:

# Define global environment variables that can be used across jobs
env:
# ACR Login Server (e.g., myregistry.azurecr.io)
# This needs to be set as a GitHub Repository Secret
ACR_LOGIN_SERVER: ${{ secrets.AZURE_CONTAINER_REGISTRY }}
# Dynamically generate image tags based on Git SHA and GitHub Run ID
IMAGE_TAG: ${{ github.sha }}-${{ github.run_id }}

jobs:
build_and_push_frontend:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- name: Login to Azure Container Registry
run: az acr login --name ${{ env.ACR_LOGIN_SERVER }}

- name: Build and Push Frontend Image
run: |
docker build -t ${{ env.ACR_LOGIN_SERVER }}/frontend:latest ./frontend/
docker push ${{ env.ACR_LOGIN_SERVER }}/frontend:latest

- name: Logout from Azure
run: az logout
if: always()
steps:
- name: Checkout repository
uses: actions/checkout@v4

# Azure login using a Service Principal secret
- name: Azure Login
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

# Login to Azure Container Registry (ACR)
- name: Login to Azure Container Registry
run: az acr login --name ${{ env.ACR_LOGIN_SERVER }}

# Build and Push Docker image for Frontend
- name: Build and Push Frontend Image
run: |
docker build -t ${{ env.ACR_LOGIN_SERVER }}/frontend:${{ env.IMAGE_TAG }} ./frontend/
docker push ${{ env.ACR_LOGIN_SERVER }}/frontend:${{ env.IMAGE_TAG }}

# Logout from Azure for security (runs even if image push fails)
- name: Logout from Azure
run: az logout
if: always()