Skip to content

Commit

Permalink
Added github actions and helm chart for testing and deploying app to …
Browse files Browse the repository at this point in the history
…openshift
  • Loading branch information
timwekkenbc committed May 6, 2024
1 parent 14c55ac commit fe9d4a1
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 0 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Build and Deploy

on:
push:
branches:
- main
- dev
- pipeline

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build_image:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
env:
NEXT_PUBLIC_API_URL: "https://brms-api-eb0f74-prod.apps.silver.devops.gov.bc.ca/api"
NEXT_PUBLIC_GO_RULES_PROJECT_ID: "5b3cafaf-0159-48a6-b5aa-d52126c127c5"
NEXT_PUBLIC_GO_RULES_BEARER_PAT: "grl_pat_1k5I78MNm3wLbR8Ey4gpU_sMWW9NElR6jBQxvip1H5OsMKBV"
NEXT_PUBLIC_GO_RULES_ACCESS_TOKEN: "UAXwXrYJchvr8LrdXaugYJmA"

outputs:
image_tag: ${{ steps.meta.outputs.tags }}

deploy:
needs: build_image
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Authenticate and set context for OpenShift
uses: redhat-actions/oc-login@v1

with:
openshift_server_url: ${{ secrets.OPENSHIFT_SERVER }}
namespace: ${{ github.ref == 'refs/heads/main' && secrets.OPENSHIFT_PROD_NAMESPACE || secrets.OPENSHIFT_DEV_NAMESPACE }}
openshift_token: ${{ github.ref == 'refs/heads/main' && secrets.OPENSHIFT_PROD_TOKEN || secrets.OPENSHIFT_DEV_TOKEN }}
insecure_skip_tls_verify: true

- name: Run Helm
run: |
helm upgrade --install brms-frontend ./helm --set image.tag=${{ needs.build_image.outputs.image_tag }}
28 changes: 28 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Test

on:
push:
branches:
- '*'
pull_request:
branches:
- '*'

jobs:
test:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: npm install

- name: Run Jest tests with coverage
run: npm test -- --coverage

- name: Upload coverage report
uses: actions/upload-artifact@v4
with:
name: coverage
path: coverage
4 changes: 4 additions & 0 deletions helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v2
name: brms-frontend
description: A Helm chart for deploying brms-frontend
version: 0.1.0
37 changes: 37 additions & 0 deletions helm/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: brms-frontend
labels:
app.kubernetes.io/name: brms-frontend
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: brms-frontend
template:
metadata:
labels:
app.kubernetes.io/name: brms-frontend
spec:
containers:
- name: brms-frontend
image: '{{ .Values.image.tag }}'
ports:
- containerPort: 8080
resources: {}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
imagePullPolicy: Always
restartPolicy: Always
terminationGracePeriodSeconds: 30
dnsPolicy: ClusterFirst
securityContext: {}
schedulerName: default-scheduler
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 25%
maxSurge: 25%
revisionHistoryLimit: 10
progressDeadlineSeconds: 600
13 changes: 13 additions & 0 deletions helm/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: brms-frontend
labels:
app.kubernetes.io/name: brms-frontend
spec:
selector:
app.kubernetes.io/name: brms-frontend
ports:
- protocol: TCP
port: 8080
targetPort: 8080

0 comments on commit fe9d4a1

Please sign in to comment.