Skip to content

Commit

Permalink
Merge pull request #3 from bcgov/dev
Browse files Browse the repository at this point in the history
Merge dev: disabled production deploy for now; updated app title and default content
  • Loading branch information
MCatherine1994 authored Jul 7, 2022
2 parents ee2b8ae + d7284c9 commit 0dbfca0
Show file tree
Hide file tree
Showing 10 changed files with 142 additions and 144 deletions.
74 changes: 37 additions & 37 deletions .github/openshift/deploy.backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,31 +38,31 @@ 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
required: true
- name: EMAIL_PASSWORD
description: CHES service client password
required: true
- name: EMAIL_TOKEN_URL
description: CHES authentication url
required: true
- name: EMAIL_API_URL
description: CHES email api url
required: true
# - name: EMAIL_USERNAME
# description: CHES service client
# required: true
# - name: EMAIL_PASSWORD
# description: CHES service client password
# required: true
# - name: EMAIL_TOKEN_URL
# description: CHES authentication url
# required: true
# - name: EMAIL_API_URL
# description: CHES email api url
# required: true
- name: NODE_ENV
description: environment mode
required: true
objects:
- apiVersion: v1
kind: Secret
metadata:
name: ${NAME}-${ZONE}-${COMPONENT}
labels:
app: ${NAME}-${ZONE}
stringData:
email-username: "${EMAIL_USERNAME}"
email-password: "${EMAIL_PASSWORD}"
# - apiVersion: v1
# kind: Secret
# metadata:
# name: ${NAME}-${ZONE}-${COMPONENT}
# labels:
# app: ${NAME}-${ZONE}
# stringData:
# email-username: "${EMAIL_USERNAME}"
# email-password: "${EMAIL_PASSWORD}"
- apiVersion: v1
kind: ImageStream
metadata:
Expand Down Expand Up @@ -133,22 +133,22 @@ objects:
value: https://${NAME}-${ZONE}-frontend.${DOMAIN}
- name: BACKEND_URL
value: https://${NAME}-${ZONE}-backend.${DOMAIN}
- name: EMAIL_USERNAME
valueFrom:
secretKeyRef:
name: ${NAME}-${ZONE}-${COMPONENT}
key: email-username
- name: EMAIL_PASSWORD
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
value: "[email protected]"
# - name: EMAIL_USERNAME
# valueFrom:
# secretKeyRef:
# name: ${NAME}-${ZONE}-${COMPONENT}
# key: email-username
# - name: EMAIL_PASSWORD
# 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
# value: "[email protected]"
- name: NODE_ENV
value: ${NODE_ENV}

Expand Down
2 changes: 1 addition & 1 deletion .github/openshift/networkPolicies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: Template
metadata:
name: ${NAME}
annotations:
description: "Nr-Forest-Client"
description: "NR-Forest-Client"
tags: "nrfl"
iconClass: icon-js
objects:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/merge-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,11 @@ 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_SERVICE_CLIENT }} \
-p EMAIL_PASSWORD=${{ secrets.CHES_CLIENT_PASSWORD }} \
-p EMAIL_TOKEN_URL='https://oidc.gov.bc.ca/auth/realms/jbd6rnxw/protocol/openid-connect/token' \
-p EMAIL_API_URL='https://ches-dev.apps.silver.devops.gov.bc.ca/api/v1' \
-p NODE_ENV='development' | oc apply -f -
# -p EMAIL_USERNAME=${{ secrets.CHES_SERVICE_CLIENT }} \
# -p EMAIL_PASSWORD=${{ secrets.CHES_CLIENT_PASSWORD }} \
# -p EMAIL_TOKEN_URL='https://oidc.gov.bc.ca/auth/realms/jbd6rnxw/protocol/openid-connect/token' \
# -p EMAIL_API_URL='https://ches-dev.apps.silver.devops.gov.bc.ca/api/v1' | oc apply -f -
oc process -f .github/openshift/deploy.frontend.yml -p ZONE=${{ env.ZONE }} \
-p PROMOTE=${{ github.repository }}:${{ env.ZONE }}-frontend | oc apply -f -
Expand Down
178 changes: 89 additions & 89 deletions .github/workflows/merge-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,11 @@ 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_SERVICE_CLIENT }} \
-p EMAIL_PASSWORD=${{ secrets.CHES_CLIENT_PASSWORD }} \
-p EMAIL_TOKEN_URL='https://oidc.gov.bc.ca/auth/realms/jbd6rnxw/protocol/openid-connect/token' \
-p EMAIL_API_URL='https://ches-dev.apps.silver.devops.gov.bc.ca/api/v1' \
-p NODE_ENV='development' | oc apply -f -
# -p EMAIL_USERNAME=${{ secrets.CHES_SERVICE_CLIENT }} \
# -p EMAIL_PASSWORD=${{ secrets.CHES_CLIENT_PASSWORD }} \
# -p EMAIL_TOKEN_URL='https://oidc.gov.bc.ca/auth/realms/jbd6rnxw/protocol/openid-connect/token' \
# -p EMAIL_API_URL='https://ches-dev.apps.silver.devops.gov.bc.ca/api/v1' | oc apply -f -
oc process -f .github/openshift/deploy.frontend.yml -p ZONE=${{ env.ZONE }} \
-p PROMOTE=${{ github.repository }}:${{ env.ZONE }}-frontend | oc apply -f -
Expand Down Expand Up @@ -281,88 +281,88 @@ jobs:
allow_issue_writing: false
fail_action: false

deploy-prod:
name: PROD Deployment
needs:
- zap-backend
- zap-frontend
runs-on: ubuntu-latest
environment:
name: prod
env:
ZONE: prod
PREV: test
steps:
- uses: actions/checkout@v2
- name: Deploy
run: |
# Login to OpenShift and select project
oc login --token=${{ secrets.OC_TOKEN }} --server=${{ secrets.OC_SERVER }}
oc project ${{ secrets.OC_NAMESPACE }}
# Clear stale images for import/replacement
if [ $(oc get is -l app=${{ env.NAME }}-${{ env.ZONE }} -o name | grep -v database | wc -l) -gt 0 ]; then
oc delete is -l app=${{ env.NAME }}-${{ env.ZONE }}
fi
# Cancel db backup rollout if exists
if [ $(oc get dc -l app=backup-container -o name | wc -l) -gt 0 ]; then
oc rollout cancel dc/${{ env.NAME }}-${{ env.ZONE }}-dbbackup 2> /dev/null \
|| true && echo "No rollout in progress"
fi
# Create frontend config (Remove the old one if exists)
oc delete configmap ${{ env.NAME }}-${{ env.ZONE }}-frontend 2> /dev/null \
|| true && echo "No existing frontend config"
oc create configmap ${{ env.NAME }}-${{ env.ZONE }}-frontend \
--from-literal=config.js="const config = (() => { return { VITE_BACKEND_URL: 'https://${{ env.NAME }}-${{ env.ZONE }}-backend.apps.silver.devops.gov.bc.ca'}; })();"
# Process and apply deployment templates
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_SERVICE_CLIENT }} \
-p EMAIL_PASSWORD=${{ secrets.CHES_CLIENT_PASSWORD }} \
-p EMAIL_TOKEN_URL='https://oidc.gov.bc.ca/auth/realms/jbd6rnxw/protocol/openid-connect/token' \
-p EMAIL_API_URL='https://ches.apps.silver.devops.gov.bc.ca/api/v1' \
-p NODE_ENV='production' | oc apply -f -
oc process -f .github/openshift/deploy.frontend.yml -p ZONE=${{ env.ZONE }} \
-p PROMOTE=${{ github.repository }}:${{ env.PREV }}-frontend | 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
oc rollout status dc/${{ env.NAME }}-${{ env.ZONE }}-frontend -w
# Remove completed build runs, build pods and deployment pods
for p in $(oc get po | grep "Completed" | awk '{print $1}')
do
oc delete po ${p}
done
# Restart db backup rollout if exists
if [ $(oc get dc -l app=backup-container -o name | wc -l) -gt 0 ]; then
oc rollout latest dc/${{ env.NAME }}-${{ env.ZONE }}-dbbackup 2> /dev/null \
|| true && echo "Rollout in progress"
oc logs -f dc/${{ env.NAME }}-${{ env.ZONE }}-dbbackup
fi
- name: Promote Backend Image to PROD
uses: shrink/actions-docker-registry-tag@v2
with:
registry: ghcr.io
repository: ${{ github.repository }}
token: ${{ secrets.GHCR_TOKEN }}
target: ${{ env.PREV }}-backend
tags: |
prod-backend
- name: Promote Frontend Image to PROD
uses: shrink/actions-docker-registry-tag@v2
with:
registry: ghcr.io
repository: ${{ github.repository }}
token: ${{ secrets.GHCR_TOKEN }}
target: ${{ env.PREV }}-frontend
tags: |
prod-frontend
# deploy-prod:
# name: PROD Deployment
# needs:
# - zap-backend
# - zap-frontend
# runs-on: ubuntu-latest
# environment:
# name: prod
# env:
# ZONE: prod
# PREV: test
# steps:
# - uses: actions/checkout@v2
# - name: Deploy
# run: |
# # Login to OpenShift and select project
# oc login --token=${{ secrets.OC_TOKEN }} --server=${{ secrets.OC_SERVER }}
# oc project ${{ secrets.OC_NAMESPACE }}

# # Clear stale images for import/replacement
# if [ $(oc get is -l app=${{ env.NAME }}-${{ env.ZONE }} -o name | grep -v database | wc -l) -gt 0 ]; then
# oc delete is -l app=${{ env.NAME }}-${{ env.ZONE }}
# fi

# # Cancel db backup rollout if exists
# if [ $(oc get dc -l app=backup-container -o name | wc -l) -gt 0 ]; then
# oc rollout cancel dc/${{ env.NAME }}-${{ env.ZONE }}-dbbackup 2> /dev/null \
# || true && echo "No rollout in progress"
# fi

# # Create frontend config (Remove the old one if exists)
# oc delete configmap ${{ env.NAME }}-${{ env.ZONE }}-frontend 2> /dev/null \
# || true && echo "No existing frontend config"
# oc create configmap ${{ env.NAME }}-${{ env.ZONE }}-frontend \
# --from-literal=config.js="const config = (() => { return { VITE_BACKEND_URL: 'https://${{ env.NAME }}-${{ env.ZONE }}-backend.apps.silver.devops.gov.bc.ca'}; })();"

# # Process and apply deployment templates
# 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 NODE_ENV='production' | oc apply -f -
# # -p EMAIL_USERNAME=${{ secrets.CHES_SERVICE_CLIENT }} \
# # -p EMAIL_PASSWORD=${{ secrets.CHES_CLIENT_PASSWORD }} \
# # -p EMAIL_TOKEN_URL='https://oidc.gov.bc.ca/auth/realms/jbd6rnxw/protocol/openid-connect/token' \
# # -p EMAIL_API_URL='https://ches.apps.silver.devops.gov.bc.ca/api/v1' | oc apply -f -
# oc process -f .github/openshift/deploy.frontend.yml -p ZONE=${{ env.ZONE }} \
# -p PROMOTE=${{ github.repository }}:${{ env.PREV }}-frontend | 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
# oc rollout status dc/${{ env.NAME }}-${{ env.ZONE }}-frontend -w

# # Remove completed build runs, build pods and deployment pods
# for p in $(oc get po | grep "Completed" | awk '{print $1}')
# do
# oc delete po ${p}
# done

# # Restart db backup rollout if exists
# if [ $(oc get dc -l app=backup-container -o name | wc -l) -gt 0 ]; then
# oc rollout latest dc/${{ env.NAME }}-${{ env.ZONE }}-dbbackup 2> /dev/null \
# || true && echo "Rollout in progress"
# oc logs -f dc/${{ env.NAME }}-${{ env.ZONE }}-dbbackup
# fi

# - name: Promote Backend Image to PROD
# uses: shrink/actions-docker-registry-tag@v2
# with:
# registry: ghcr.io
# repository: ${{ github.repository }}
# token: ${{ secrets.GHCR_TOKEN }}
# target: ${{ env.PREV }}-backend
# tags: |
# prod-backend

# - name: Promote Frontend Image to PROD
# uses: shrink/actions-docker-registry-tag@v2
# with:
# registry: ghcr.io
# repository: ${{ github.repository }}
# token: ${{ secrets.GHCR_TOKEN }}
# target: ${{ env.PREV }}-frontend
# tags: |
# prod-frontend
11 changes: 7 additions & 4 deletions .github/workflows/pr-open.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
with:
registry: ${{ env.REGISTRY }}
repository: ${{ github.repository }}
token: ${{ secrets.GHCR_TOKEN }}
target: prod-backend
tags: |
${{ github.event.number }}-backend
Expand Down Expand Up @@ -91,6 +92,7 @@ jobs:
with:
registry: ${{ env.REGISTRY }}
repository: ${{ github.repository }}
token: ${{ secrets.GHCR_TOKEN }}
target: prod-frontend
tags: |
${{ github.event.number }}-frontend
Expand Down Expand Up @@ -356,11 +358,12 @@ 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_SERVICE_CLIENT }} \
-p EMAIL_PASSWORD=${{ secrets.CHES_CLIENT_PASSWORD }} \
-p EMAIL_TOKEN_URL='https://dev.oidc.gov.bc.ca/auth/realms/jbd6rnxw/protocol/openid-connect/token' \
-p EMAIL_API_URL='https://ches-dev.apps.silver.devops.gov.bc.ca/api/v1' \
-p NODE_ENV='development' | oc apply -f -
# -p EMAIL_USERNAME=${{ secrets.CHES_SERVICE_CLIENT }} \
# -p EMAIL_PASSWORD=${{ secrets.CHES_CLIENT_PASSWORD }} \
# -p EMAIL_TOKEN_URL='https://dev.oidc.gov.bc.ca/auth/realms/jbd6rnxw/protocol/openid-connect/token' \
# -p EMAIL_API_URL='https://ches-dev.apps.silver.devops.gov.bc.ca/api/v1' | oc apply -f -
# Clean previous image, if rebuilding
if [ ${{ needs.build-backend.outputs.build == 'true' }} ]
Expand Down
3 changes: 0 additions & 3 deletions backend/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ async function bootstrap() {
if (!origin || whitelist.indexOf(origin) !== -1) {
callback(null, true);
}
// else {
// callback(new Error('Not allowed by CORS'));
// }
},
});

Expand Down
2 changes: 1 addition & 1 deletion frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"
integrity="sha512-XQoYMqMTK8LvdxXYG3nZ448hOEQiglfqkJs1NOQV44cWnUrBc8PkAOcXy20w0vlaXaVUearIOBhiXZ5V3ynxwA=="
crossorigin=""></script>
<title>Old growth</title>
<title>Forest Client</title>
</head>
<body>
<div id="app"></div>
Expand Down
4 changes: 1 addition & 3 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,19 @@
<div>
<MainHeader />
<b-container>
<NewFormSubmission />
Hello World !
</b-container>
</div>
</template>

<script lang="ts">
import { defineComponent } from "vue";
import MainHeader from "./common/MainHeader.vue";
import NewFormSubmission from "./pages/NewFormSubmission.vue";
export default defineComponent({
name: "App",
components: {
MainHeader,
NewFormSubmission,
},
data() {
return {};
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/common/MainHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
alt="Go to the Government of British Columbia website"
/>
</a>
<h1>FSA - Old Growth</h1>
<h1>FSA - Forest Client</h1>
</div>
</header>
</template>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/tests/MainHeader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ import MainHeader from "../common/MainHeader.vue";
describe("MainHeader", () => {
it("renders properly", () => {
const wrapper = mount(MainHeader);
expect(wrapper.text()).toContain("FSA - Old Growth");
expect(wrapper.text()).toContain("FSA - Forest Client");
});
});

0 comments on commit 0dbfca0

Please sign in to comment.