Skip to content

Commit b9b198d

Browse files
GitHub Action for Helm Deployment (#39)
2 parents 646f1ad + e054401 commit b9b198d

File tree

4 files changed

+107
-4
lines changed

4 files changed

+107
-4
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# This workflow runs tests, builds, and publishes the images. It performs no deployment.
2+
# It runs on all branches when code is pushed to ensure tests pass and images are available for testing purposes.
3+
name: Build & Test Meet@Mensa
4+
5+
# Run on all branches except main
6+
on:
7+
push:
8+
branches-ignore:
9+
- main
10+
11+
jobs:
12+
13+
# Run tests (unimplemented)
14+
# test:
15+
# name: Run Tests
16+
# uses: ./.github/workflows/test_application.yml
17+
18+
# Call the docker_build workflow to build and publish images
19+
build:
20+
name: Build & Publish Images
21+
uses: ./.github/workflows/docker_build.yml
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# This workflow builds and publishes the images, then deploys them to the Kubernetes cluster.
2+
# It runs only when code is pushed to the main branch, and is thus considered ready for production.
3+
name: Deploy Meet@Mensa
4+
5+
on:
6+
workflow_dispatch:
7+
push:
8+
branches:
9+
- main
10+
11+
jobs:
12+
13+
# Run tests (unimplemented)
14+
# test:
15+
# name: Run Tests
16+
# uses: ./.github/workflows/test_application.yml
17+
18+
# Call the docker_build workflow to build and publish images
19+
build:
20+
name: Build & Publish Images
21+
uses: ./.github/workflows/docker_build.yml
22+
23+
# Call the kubernetes_deploy workflow to deploy to Rancher
24+
deploy_kubernetes:
25+
name: Deploy to Kubernetes Cluster
26+
needs: build # wait for build to complete before running
27+
uses: ./.github/workflows/kubernetes_deploy.yml
28+
secrets: # Pass KUBECONFIG to called workflow
29+
KUBECONFIG: ${{ secrets.KUBECONFIG }}
30+
31+
# Call the aws_deploy workflow to deploy to AWS
32+
# deploy_aws:
33+
# name: Deploy to AWS
34+
# needs: build
35+
# uses: ./.github/workflows/aws_deploy.yml

.github/workflows/docker_build.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
# This workflow should build docker images every time code is pushed to the repository
2-
name: Build Docker Images
2+
name: Build and Publish Docker Images
33

4+
# This workflow is triggered only when called by another workflow
45
on:
5-
push:
6+
workflow_call:
67

7-
# List of jobs to be run
88
jobs:
99

1010
build:
1111
name: Build Docker Images
1212
runs-on: ubuntu-latest
13-
strategy: # Use a matrix strategy to run the build process for all our containers
13+
14+
# Use a matrix strategy to run the build process for all our containers
15+
strategy:
1416
matrix:
1517
# Add any future services relative paths from . here
1618
service: [client, server/chat, server/gateway, server/matching, server/user, genai]
19+
1720
steps:
1821

1922
# Use pre-existing action to login to GHCR.io
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# This workflow should deploy meet@mensa to the chair's Rancher Kubernetes cluster every time code is pushed into main branch
2+
name: Deploy to Kubernetes Cluster
3+
4+
# This workflow is triggered only when called by another workflow
5+
on:
6+
workflow_call:
7+
8+
# Pass KUBECONFIG as a secret
9+
secrets:
10+
KUBECONFIG:
11+
required: true
12+
13+
jobs:
14+
15+
deploy:
16+
runs-on: ubuntu-latest
17+
steps:
18+
19+
# Checkout git repo
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
# Use Azure's kubectl installation action
24+
- name: Install Kubectl
25+
uses: azure/setup-kubectl@v4
26+
with:
27+
version: latest
28+
29+
# Use Azure's helm installation action
30+
- name: Install Helm
31+
uses: azure/[email protected]
32+
with:
33+
version: latest
34+
35+
# Copy the details of Kubeconfig to enable authentication with the Rancher cluster
36+
- name: Load Kubeconfig
37+
run: |
38+
mkdir -p ~/.kube
39+
printf "%s" "${{ secrets.KUBECONFIG }}" > ~/.kube/config
40+
41+
# Run helm upgrade to upgrade deployment
42+
- name: Upgrade Deployment with Helm
43+
run: |
44+
helm upgrade --install meetatmensa ./deployment/k8s -n devoops

0 commit comments

Comments
 (0)