Skip to content
Open
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
25 changes: 5 additions & 20 deletions .github/workflows/01-ci.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
name: 01 - CI

on:
# Trigger the workflow on push to main branch
pull_request:
branches:
- main

push:
branches:
- main

# Manual trigger for the workflow
workflow_dispatch:

workflow_dispatch:

jobs:

# =========================================================
# Backend Tests
# =========================================================
backend-test:
name: Test ${{ matrix.service }}
runs-on: ubuntu-latest

strategy:
fail-fast: false

matrix:
include:
- service: user-service
Expand Down Expand Up @@ -68,20 +64,16 @@ jobs:
POSTGRES_DB: ${{ matrix.database }}
POSTGRES_HOST: localhost
POSTGRES_PORT: ${{ matrix.port }}

JWT_SECRET_KEY: koalatech-ci-test-secret
JWT_ALGORITHM: HS256
ACCESS_TOKEN_EXPIRE_MINUTES: 30

DEFAULT_ADMIN_USERNAME: admin
DEFAULT_ADMIN_EMAIL: admin@koalatech.edu.au
DEFAULT_ADMIN_PASSWORD: AdminPassword123!

AZURE_STORAGE_CONNECTION_STRING: ""
AZURE_STORAGE_CONTAINER_NAME: ""

steps:

- name: Checkout repository
uses: actions/checkout@v4

Expand All @@ -102,23 +94,17 @@ jobs:
pytest -v


# =========================================================
# Build and Push Docker Images
# =========================================================
build-and-push:
name: Build and Push ${{ matrix.image }}
runs-on: ubuntu-latest

# All backend tests must pass before this job starts
needs:
- backend-test

# Build and push when code is pushed to main or manually triggered
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'

strategy:
fail-fast: false

matrix:
include:
- service: frontend
Expand All @@ -140,7 +126,6 @@ jobs:
image: koalatech-enrollment-service

steps:

- name: Checkout repository
uses: actions/checkout@v4

Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/02-deploy-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ jobs:
name: Deploy to Staging
runs-on: ubuntu-latest

if: >
${{ github.event.workflow_run.conclusion == 'success' }}

if: ${{ github.event.workflow_run.conclusion == 'success' }}
environment:
name: staging

Expand Down Expand Up @@ -148,4 +146,4 @@ jobs:
run: |
kubectl get pods -n staging
kubectl get services -n staging
kubectl get pvc -n staging
kubectl get pvc -n staging
34 changes: 23 additions & 11 deletions .github/workflows/04-deploy-production.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,37 @@
name: 04 - Deploy to Production

on:
workflow_run:
workflows:
- "03 - Test Staging"
types:
- completed
branches:
- main

workflow_dispatch:
inputs:
image_tag:
description: "Tested image SHA to deploy"
required: true
type: string

jobs:
deploy-production:
name: Deploy to Production
runs-on: ubuntu-latest
if: >
${{ (github.event_name == 'workflow_run' &&
github.event.workflow_run.conclusion == 'success') ||
github.event_name == 'workflow_dispatch' }}

env:
IMAGE_TAG: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_sha || inputs.image_tag }}
environment:
name: production

steps:
- name: Checkout repository
uses: actions/checkout@v4

with:
ref: ${{ env.IMAGE_TAG }}
- name: Login to Azure
uses: azure/login@v3
with:
Expand Down Expand Up @@ -69,37 +81,37 @@ jobs:
- name: Update frontend image
run: |
kubectl set image deployment/frontend \
frontend=${{ vars.ACR_LOGIN_SERVER }}/koalatech-frontend:${{ inputs.image_tag }} \
frontend=${{ vars.ACR_LOGIN_SERVER }}/koalatech-frontend:${{ env.IMAGE_TAG }} \
-n production

- name: Update user-service image
run: |
kubectl set image deployment/user-service \
user-service=${{ vars.ACR_LOGIN_SERVER }}/koalatech-user-service:${{ inputs.image_tag }} \
user-service=${{ vars.ACR_LOGIN_SERVER }}/koalatech-user-service:${{ env.IMAGE_TAG }} \
-n production

- name: Update student-service image
run: |
kubectl set image deployment/student-service \
student-service=${{ vars.ACR_LOGIN_SERVER }}/koalatech-student-service:${{ inputs.image_tag }} \
student-service=${{ vars.ACR_LOGIN_SERVER }}/koalatech-student-service:${{ env.IMAGE_TAG }} \
-n production

- name: Update lecturer-service image
run: |
kubectl set image deployment/lecturer-service \
lecturer-service=${{ vars.ACR_LOGIN_SERVER }}/koalatech-lecturer-service:${{ inputs.image_tag }} \
lecturer-service=${{ vars.ACR_LOGIN_SERVER }}/koalatech-lecturer-service:${{ env.IMAGE_TAG }} \
-n production

- name: Update course-service image
run: |
kubectl set image deployment/course-service \
course-service=${{ vars.ACR_LOGIN_SERVER }}/koalatech-course-service:${{ inputs.image_tag }} \
course-service=${{ vars.ACR_LOGIN_SERVER }}/koalatech-course-service:${{ env.IMAGE_TAG }} \
-n production

- name: Update enrollment-service image
run: |
kubectl set image deployment/enrollment-service \
enrollment-service=${{ vars.ACR_LOGIN_SERVER }}/koalatech-enrollment-service:${{ inputs.image_tag }} \
enrollment-service=${{ vars.ACR_LOGIN_SERVER }}/koalatech-enrollment-service:${{ env.IMAGE_TAG }} \
-n production

- name: Wait for frontend rollout
Expand Down Expand Up @@ -142,4 +154,4 @@ jobs:
run: |
kubectl get pods -n production
kubectl get services -n production
kubectl get pvc -n production
kubectl get pvc -n production
2 changes: 1 addition & 1 deletion frontend/src/pages/Dashboard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ const Dashboard = () => {
</Typography>

<Typography color="text.secondary">
Welcome to KoalaTech University
Welcome to KoalaTech University - Continuous Deployment
</Typography>
</Box>

Expand Down
3 changes: 2 additions & 1 deletion user-service/app/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Week 8 continuous delivery pipeline test enabled
import logging
import os
import time
Expand Down Expand Up @@ -138,4 +139,4 @@ def health_check() -> dict[str, str]:
return {
"status": "healthy",
"service": "user-service",
}
}