Skip to content

Commit

Permalink
Merge pull request #100 from bcgov/dev
Browse files Browse the repository at this point in the history
Merge #89: Add email notification when a licensee updates submission in CHEFS
  • Loading branch information
MCatherine1994 authored Jan 9, 2023
2 parents 82110b8 + ff6dc39 commit ddcbf3b
Show file tree
Hide file tree
Showing 18 changed files with 2,176 additions and 3,216 deletions.
45 changes: 26 additions & 19 deletions .github/openshift/deploy.backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ parameters:
- name: PROMOTE
description: Image (namespace/name:tag) to promote/import
value: bcgov/nr-old-growth:prod-backend
- name: EMAIL_USERNAME
description: CHES service client
- name: CHES_CLIENT_ID
description: CHES service client id
required: true
- name: EMAIL_PASSWORD
description: CHES service client password
- name: CHES_CLIENT_SECRET
description: CHES service client secret
required: true
- name: EMAIL_TOKEN_URL
description: CHES authentication url
- name: CHES_TOKEN_URL
description: CHES service authentication url
required: true
- name: EMAIL_API_URL
description: CHES email api url
- name: CHES_API_URL
description: CHES service api url
required: true
- name: NODE_ENV
description: environment mode
Expand All @@ -67,8 +67,8 @@ objects:
labels:
app: ${NAME}-${ZONE}
stringData:
email-username: "${EMAIL_USERNAME}"
email-password: "${EMAIL_PASSWORD}"
ches-client-id: "${CHES_CLIENT_ID}"
ches-client-secret: "${CHES_CLIENT_SECRET}"
idir-form-password: "${IDIR_FORM_PASSWORD}"
bceid-form-password: "${BCEID_FORM_PASSWORD}"
- apiVersion: v1
Expand Down Expand Up @@ -141,24 +141,31 @@ objects:
value: https://${NAME}-${ZONE}-frontend.${DOMAIN}
- name: BACKEND_URL
value: https://${NAME}-${ZONE}-backend.${DOMAIN}
- name: EMAIL_USERNAME
- name: CHES_CLIENT_ID
valueFrom:
secretKeyRef:
name: ${NAME}-${ZONE}-${COMPONENT}
key: email-username
- name: EMAIL_PASSWORD
key: ches-client-id
- name: CHES_CLIENT_SECRET
valueFrom:
secretKeyRef:
name: ${NAME}-${ZONE}-${COMPONENT}
key: email-password
- name: EMAIL_TOKEN_URL
value: ${EMAIL_TOKEN_URL}
- name: EMAIL_API_URL
value: ${EMAIL_API_URL}
- name: EMAIL_FROM
key: ches-client-secret
- name: CHES_TOKEN_URL
value: ${CHES_TOKEN_URL}
- name: CHES_API_URL
value: ${CHES_API_URL}
- name: CHES_EMAIL_FROM
value: "[email protected]"
- name: NODE_ENV
value: ${NODE_ENV}
# test form
# - name: IDIR_FORM_ID
# value: "b6803f31-269b-4406-8cc7-b2bdc80d94dc"
# - name: IDIR_FORM_VERSION_ID
# value: "21bae274-5f36-4fd7-a14e-89787c468824"
# - name: IDIR_FORM_PASSWORD
# value: ""
- name: IDIR_FORM_ID
value: "b15b1975-3caa-4984-a183-471c5610c8a5"
- name: IDIR_FORM_VERSION_ID
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/merge-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,17 +139,16 @@ jobs:
oc process -f .github/openshift/deploy.database.yml -p ZONE=${{ env.ZONE }} | oc apply -f -
oc process -f .github/openshift/deploy.backend.yml -p ZONE=${{ env.ZONE }} \
-p PROMOTE=${{ github.repository }}:${{ env.ZONE }}-backend \
-p EMAIL_USERNAME=${{ secrets.CHES_CLIENT_ID }} \
-p EMAIL_PASSWORD=${{ secrets.CHES_CLIENT_SECRET }} \
-p EMAIL_TOKEN_URL='https://test.loginproxy.gov.bc.ca/auth/realms/comsvcauth/protocol/openid-connect/token' \
-p EMAIL_API_URL='https://ches-test.api.gov.bc.ca/api/v1' \
-p CHES_CLIENT_ID=${{ secrets.CHES_CLIENT_ID }} \
-p CHES_CLIENT_SECRET=${{ secrets.CHES_CLIENT_SECRET }} \
-p CHES_TOKEN_URL='https://test.loginproxy.gov.bc.ca/auth/realms/comsvcauth/protocol/openid-connect/token' \
-p CHES_API_URL='https://ches-test.api.gov.bc.ca/api/v1' \
-p NODE_ENV='development' \
-p BCEID_FORM_PASSWORD=${{ secrets.CHEFS_BCEID_FORM_PASSWORD}} \
-p IDIR_FORM_PASSWORD=${{ secrets.CHEFS_IDIR_FORM_PASSWORD}} | oc apply -f -
# Follow any active rollouts (see deploymentconfigs)
oc rollout status dc/${{ env.NAME }}-${{ env.ZONE }}-database -w
oc rollout status dc/${{ env.NAME }}-${{ env.ZONE }}-backend -w
# Remove completed build runs, build pods and deployment pods
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/merge-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@ jobs:
oc process -f .github/openshift/deploy.database.yml -p ZONE=${{ env.ZONE }} | oc apply -f -
oc process -f .github/openshift/deploy.backend.yml -p ZONE=${{ env.ZONE }} \
-p PROMOTE=${{ github.repository }}:${{ env.ZONE }}-backend \
-p EMAIL_USERNAME=${{ secrets.CHES_CLIENT_ID }} \
-p EMAIL_PASSWORD=${{ secrets.CHES_CLIENT_SECRET }} \
-p EMAIL_TOKEN_URL='https://test.loginproxy.gov.bc.ca/auth/realms/comsvcauth/protocol/openid-connect/token' \
-p EMAIL_API_URL='https://ches-test.api.gov.bc.ca/api/v1' \
-p CHES_CLIENT_ID=${{ secrets.CHES_CLIENT_ID }} \
-p CHES_CLIENT_SECRET=${{ secrets.CHES_CLIENT_SECRET }} \
-p CHES_TOKEN_URL='https://test.loginproxy.gov.bc.ca/auth/realms/comsvcauth/protocol/openid-connect/token' \
-p CHES_API_URL='https://ches-test.api.gov.bc.ca/api/v1' \
-p NODE_ENV='development' \
-p BCEID_FORM_PASSWORD=${{ secrets.CHEFS_BCEID_FORM_PASSWORD}} \
-p IDIR_FORM_PASSWORD=${{ secrets.CHEFS_IDIR_FORM_PASSWORD}} | oc apply -f -
Expand Down Expand Up @@ -207,10 +207,10 @@ jobs:
oc process -f .github/openshift/deploy.database.yml -p ZONE=${{ env.ZONE }} | oc apply -f -
oc process -f .github/openshift/deploy.backend.yml -p ZONE=${{ env.ZONE }} \
-p PROMOTE=${{ github.repository }}:${{ env.PREV }}-backend \
-p EMAIL_USERNAME=${{ secrets.CHES_CLIENT_ID }} \
-p EMAIL_PASSWORD=${{ secrets.CHES_CLIENT_SECRET }} \
-p EMAIL_TOKEN_URL='https://loginproxy.gov.bc.ca/auth/realms/comsvcauth/protocol/openid-connect/token' \
-p EMAIL_API_URL='https://ches.api.gov.bc.ca/api/v1' \
-p CHES_CLIENT_ID=${{ secrets.CHES_CLIENT_ID }} \
-p CHES_CLIENT_SECRET=${{ secrets.CHES_CLIENT_SECRET }} \
-p CHES_TOKEN_URL='https://loginproxy.gov.bc.ca/auth/realms/comsvcauth/protocol/openid-connect/token' \
-p CHES_API_URL='https://ches.api.gov.bc.ca/api/v1' \
-p NODE_ENV='production' \
-p BCEID_FORM_PASSWORD=${{ secrets.CHEFS_BCEID_FORM_PASSWORD}} \
-p IDIR_FORM_PASSWORD=${{ secrets.CHEFS_IDIR_FORM_PASSWORD}} | oc apply -f -
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/pr-open.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,14 @@ jobs:
# Process and apply template
oc process -f .github/openshift/deploy.backend.yml -p ZONE=${{ env.ZONE }} \
-p PROMOTE=${{ github.repository }}:${{ env.ZONE }}-backend \
-p EMAIL_USERNAME=${{ secrets.CHES_CLIENT_ID }} \
-p EMAIL_PASSWORD=${{ secrets.CHES_CLIENT_SECRET }} \
-p EMAIL_TOKEN_URL='https://dev.loginproxy.gov.bc.ca/auth/realms/comsvcauth/protocol/openid-connect/token' \
-p EMAIL_API_URL='https://ches-dev.api.gov.bc.ca/api/v1' \
-p CHES_CLIENT_ID=${{ secrets.CHES_CLIENT_ID }} \
-p CHES_CLIENT_SECRET=${{ secrets.CHES_CLIENT_SECRET }} \
-p CHES_TOKEN_URL='https://dev.loginproxy.gov.bc.ca/auth/realms/comsvcauth/protocol/openid-connect/token' \
-p CHES_API_URL='https://ches-dev.api.gov.bc.ca/api/v1' \
-p NODE_ENV='development' \
-p BCEID_FORM_PASSWORD=${{ secrets.CHEFS_BCEID_FORM_PASSWORD}} \
-p IDIR_FORM_PASSWORD=${{ secrets.CHEFS_IDIR_FORM_PASSWORD}} | oc apply -f -
# Follow any active rollouts (see deploymentconfigs)
oc rollout status dc/${{ env.NAME }}-${{ env.ZONE }}-database -w
Expand Down
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,18 @@ The Old Growth Technical Advisory Panel identified old growth areas that are at
# Overview

The nr-old-growth is a node.js application built with [nestJS](https://docs.nestjs.com), integrated with the [greenfield-template](https://github.com/bcgov/greenfield-template) to automate the process for testing, security scanning, code quality checking, image building and deploying.
For the fist version of the Old Growth project, we use [CHEFS](https://bcgov.github.io/common-service-showcase/services/chefs.html) to manage the submission and review of the field verification form. The nr-old-growth applicatin is developed based on the [CHEFS API](https://chefs.nrs.gov.bc.ca/app/api/v1/docs#operation/listSubmissions), that provides an notification system to notify the selected natural resource district office whenever there is a new submission. Using a postgres database to track notification delivery status of submissions and any error log messages.
For the currrent version of the Old Growth project, we use [CHEFS](https://bcgov.github.io/common-service-showcase/services/chefs.html) to manage the submission and review of the field verification form. The nr-old-growth applicatin is developed based on the [CHEFS API](https://chefs.nrs.gov.bc.ca/app/api/v1/docs#operation/listSubmissions), that provides an notification system to notify the selected natural resource district office whenever there is a new submission. Using a postgres database to track notification delivery status of submissions and any error log messages.

- Use the [CHEFS API](https://submit.digital.gov.bc.ca/app/api/v1/docs#tag/Submission/operation/listSubmissions) to get a list of submissions for the current form version (only the api by form version can return the submission data)
- Check if this is a new submission
- createdAt time within last cron job interval and has no record in our db, or
- has no record in our db, or
- our record for this confirmation id indicates a failure code
- Check if this is an update submission
- updatedAt time within the last cron job interval, and updatedBy=createdBy and has no record (type update, same submission update time) in our db, or
- updated (updatedBy=createdBy) but has no record (type update) in our db (happened during application downtime) and update time is after we enabling the update email service (2023-01-09), or
- our records (for update) for this confirmation id and this updatedAt time indicates a failure code
- Send email notification for the new and update submissions

# Setup

Expand All @@ -32,3 +43,7 @@ Vetur

**Enable prettier format**:
Press "option+shift+f" and select prettier as the formatter

# Note

The self-host-solution branch has the code for self hosted solutions, is not currently in use.
2 changes: 1 addition & 1 deletion backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The backend for nr-old-growth project is written in [NestJS](https://github.com/

## Setup local development

- Create a .env file inside this backend folder with the following options:
- Create a .env file inside this backend folder with the following options. **Please only set "NODE_ENV=production" in production deployment, for local, please set "NODE_ENV=development"**, so it won't send the real email

```
NODE_ENV=development
Expand Down
Loading

0 comments on commit ddcbf3b

Please sign in to comment.