diff --git a/.github/workflows/pr-open.yml b/.github/workflows/pr-open.yml index f6cc7cd..a121416 100644 --- a/.github/workflows/pr-open.yml +++ b/.github/workflows/pr-open.yml @@ -97,7 +97,7 @@ jobs: overwrite: true parameters: -p ROUTE=pubcode-${{ github.event.number }}.apps.silver.devops.gov.bc.ca - -p MIN_REPLICAS=1 -p MAX_REPLICAS=2 -p MEMORY_REQUEST=75Mi -p MEMORY_LIMIT=150Mi -p CPU_REQUEST=100m -p CPU_LIMIT=125m + -p MIN_REPLICAS=1 -p MAX_REPLICAS=2 -p MEMORY_REQUEST=75Mi -p MEMORY_LIMIT=150Mi -p CPU_REQUEST=100m -p CPU_LIMIT=125m -p VITE_SCHEMA_BRANCH=${{ github.event.pull_request.head.ref }} steps: - uses: bcgov-nr/action-deployer-openshift@v1.1.1 diff --git a/frontend/Caddyfile b/frontend/Caddyfile index a6aefc8..b80e6d1 100644 --- a/frontend/Caddyfile +++ b/frontend/Caddyfile @@ -13,6 +13,10 @@ } encode gzip + handle /config.js { + header Content-Type "text/javascript" + respond `window.config = {"VITE_SCHEMA_BRANCH":"{$VITE_SCHEMA_BRANCH}"};` + } handle { root * /app/dist try_files {path} {path}/ /index.html diff --git a/frontend/env.js b/frontend/env.js new file mode 100644 index 0000000..2e447a1 --- /dev/null +++ b/frontend/env.js @@ -0,0 +1,4 @@ + + +// eslint-disable-next-line import/prefer-default-export +export const env = { ...import.meta.env, ...window.config }; diff --git a/frontend/index.html b/frontend/index.html index 79050cf..f70b5c9 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -5,6 +5,7 @@ BCGov Public Code +
diff --git a/frontend/openshift.deploy.yml b/frontend/openshift.deploy.yml index d5f2d07..5055f5e 100644 --- a/frontend/openshift.deploy.yml +++ b/frontend/openshift.deploy.yml @@ -42,6 +42,9 @@ parameters: - name: LOG_LEVEL description: Caddy logging level DEBUG, INFO, WARN, ERROR, PANIC, and FATAL (https://github.com/caddyserver/caddy/blob/master/logging.go) value: "info" + - name: VITE_SCHEMA_BRANCH + description: Vite schema branch to use + value: "main" # override with values for PR based deployment. objects: - apiVersion: v1 kind: ImageStream @@ -97,6 +100,8 @@ objects: env: - name: LOG_LEVEL value: ${LOG_LEVEL} + - name: VITE_SCHEMA_BRANCH + value: ${VITE_SCHEMA_BRANCH} ports: - containerPort: 3000 protocol: TCP diff --git a/frontend/src/components/FormComponent.jsx b/frontend/src/components/FormComponent.jsx index 038fa49..756de10 100644 --- a/frontend/src/components/FormComponent.jsx +++ b/frontend/src/components/FormComponent.jsx @@ -2,13 +2,14 @@ import React, { useEffect, useState } from "react"; import Form from "@rjsf/material-ui"; import validator from "@rjsf/validator-ajv8"; import * as YAML from "js-yaml"; -//import * as localSchema from "../../../schema/bcgovpubcode.json"; +import { env } from "../../env"; +//import * as localSchema from "../../../schema/bcgovpubcode.json"; // uncmmment this line for local schema for testing import { useLocation, useNavigate } from "react-router"; import { Backdrop, CircularProgress } from "@material-ui/core"; import * as _ from "lodash"; // below props needs to be treated properly for the form to work properly as the nesting does not work if they are undefined. const props = ["product_information.business_capabilities_standard", "product_technology_information.ci_cd_tools", "product_technology_information.data_storage_platforms", "product_technology_information.frontend_frameworks", "product_technology_information.hosting_platforms", "product_technology_information.spatial_mapping_technologies", "product_external_dependencies.common_components", "product_external_dependencies.identity_authorization"]; - +const jsonSchemaBranch = env.VITE_SCHEMA_BRANCH || "main"; function removeBlankFields(jsonData) { if (jsonData) { for (const replaceProp of props) { @@ -57,13 +58,14 @@ const FormComponent = () => { }); const [schema, setSchema] = useState(null); + //const [schema, setSchema] = useState(localSchema); // uncomment this line for local schema for testing const [error, setError] = useState(null); const navigate = useNavigate(); useEffect(() => { async function fetchData() { try { const response = await fetch( - "https://raw.githubusercontent.com/bcgov/pubcode/main/schema/bcgovpubcode.json" + `https://raw.githubusercontent.com/bcgov/pubcode/${jsonSchemaBranch}/schema/bcgovpubcode.json` ); const data = await response.json(); setSchema(data); diff --git a/schema/bcgovpubcode.json b/schema/bcgovpubcode.json index 018349f..48bd53c 100644 --- a/schema/bcgovpubcode.json +++ b/schema/bcgovpubcode.json @@ -119,7 +119,7 @@ "ministry": { "uniqueItems": true, "title": "Ministry", - "description": "This key contains the ministry name. link: https://www2.gov.bc.ca/gov/content/governments/organizational-structure/ministries-organizations/ministries", + "description": "This key contains the ministry name. -> link: https://www2.gov.bc.ca/gov/content/governments/organizational-structure/ministries-organizations/ministries", "type": "array", "items": { "enum": [ @@ -739,4 +739,4 @@ ], "title": "JSON schema for bcgovpubcode.yml", "type": "object" -} \ No newline at end of file +}