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
90 changes: 30 additions & 60 deletions .github/workflows/04-deploy-production.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
name: 04 - Deploy to Production

on:
workflow_dispatch:
inputs:
image_tag:
description: "Tested image SHA to deploy"
required: true
type: string
workflow_run:
workflows:
- "03 - Test Staging"
types:
- completed
branches:
- main

jobs:
deploy-production:
name: Deploy to Production
runs-on: ubuntu-latest

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

environment:
name: production

steps:
- name: Checkout repository
- name: Checkout tested commit
uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_sha }}

- name: Login to Azure
uses: azure/login@v3
Expand Down Expand Up @@ -63,80 +69,44 @@ jobs:

- name: Apply Kubernetes manifests
run: |
kubectl apply \
-f kubernetes/production/
kubectl apply -f kubernetes/production/

- name: Update frontend image
- name: Deploy tested images
run: |
IMAGE_TAG="${{ github.event.workflow_run.head_sha }}"

kubectl set image deployment/frontend \
frontend=${{ vars.ACR_LOGIN_SERVER }}/koalatech-frontend:${{ inputs.image_tag }} \
frontend=${{ vars.ACR_LOGIN_SERVER }}/koalatech-frontend:$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:$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:$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:$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:$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:$IMAGE_TAG \
-n production

- name: Wait for frontend rollout
run: |
kubectl rollout status deployment/frontend \
-n production \
--timeout=300s

- name: Wait for user-service rollout
run: |
kubectl rollout status deployment/user-service \
-n production \
--timeout=300s

- name: Wait for student-service rollout
run: |
kubectl rollout status deployment/student-service \
-n production \
--timeout=300s

- name: Wait for lecturer-service rollout
run: |
kubectl rollout status deployment/lecturer-service \
-n production \
--timeout=300s

- name: Wait for course-service rollout
run: |
kubectl rollout status deployment/course-service \
-n production \
--timeout=300s

- name: Wait for enrollment-service rollout
- name: Wait for production rollouts
run: |
kubectl rollout status deployment/enrollment-service \
-n production \
--timeout=300s
kubectl rollout status deployment/frontend -n production --timeout=300s
kubectl rollout status deployment/user-service -n production --timeout=300s
kubectl rollout status deployment/student-service -n production --timeout=300s
kubectl rollout status deployment/lecturer-service -n production --timeout=300s
kubectl rollout status deployment/course-service -n production --timeout=300s
kubectl rollout status deployment/enrollment-service -n production --timeout=300s

- name: Show production resources
run: |
Expand Down
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
S226051707 | KoalaTech Live Deployment
</Typography>
</Box>

Expand Down
1 change: 1 addition & 0 deletions user-service/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Week 08 CI/CD demonstration