-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added github actions and helm chart for testing and deploying app to …
…openshift
- Loading branch information
1 parent
14c55ac
commit de43f91
Showing
6 changed files
with
159 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
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 }} | ||
|
||
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 --values ./helm/values.yaml --set image.tag=${{ needs.build_image.outputs.image_tag }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
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 | ||
env: | ||
- name: NEXT_PUBLIC_API_URL | ||
value: "{{ .Values.environmentVariables.NEXT_PUBLIC_API_URL }}" | ||
- name: NEXT_PUBLIC_GO_RULES_PROJECT_ID | ||
value: "{{ .Values.environmentVariables.NEXT_PUBLIC_GO_RULES_PROJECT_ID }}" | ||
- name: NEXT_PUBLIC_GO_RULES_BEARER_PAT | ||
value: "{{ .Values.environmentVariables.NEXT_PUBLIC_GO_RULES_BEARER_PAT }}" | ||
- name: NEXT_PUBLIC_GO_RULES_ACCESS_TOKEN | ||
value: "{{ .Values.environmentVariables.NEXT_PUBLIC_GO_RULES_ACCESS_TOKEN }}" | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
environmentVariables: | ||
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" |