Skip to content

Commit

Permalink
Merge pull request #518 from codeforboston/mattdelsordo/ui-staging
Browse files Browse the repository at this point in the history
provide git metadata in workflow
  • Loading branch information
mattdelsordo authored Dec 15, 2023
2 parents 3875672 + 1fa7a2a commit f79e139
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ jobs:
context: frontend/front
port: 8080
build-args: |
REACT_APP_GIT_SHA=${{ github.sha }}
REACT_APP_GIT_REF=${{ github.ref_name }}
REACT_APP_RECAPTCHA_KEY=6LdHAxYmAAAAAHGN0eNzJhGpCrxm7FisXyZoy8cr
REACT_APP_PUBLIC_SURVEY_ENABLED='false'
REACT_APP_API_URL=${{ github.event_name == 'release' && 'https://api.bostonhpa.org' || 'https://api.staging.bostonhpa.org' }}
4 changes: 2 additions & 2 deletions frontend/front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"web-vitals": "^2.1.0"
},
"scripts": {
"start": "cross-env REACT_APP_GIT_SHA=$(git rev-parse --short HEAD) PORT=3001 react-scripts start",
"build": "cross-env REACT_APP_GIT_SHA=$(git rev-parse --short HEAD) react-scripts build",
"start": "PORT=3001 react-scripts start",
"build": "react-scripts build",
"serve": "serve -l 3001 build/",
"test": "react-scripts test",
"test-style": "run-s lint prettier",
Expand Down
5 changes: 4 additions & 1 deletion frontend/front/src/pages/Metadata.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { useMemo } from "react";

const MISSING_MESSAGE = "This value should be supplied by the GitHub workflow";

export const Metadata = () => {
const metadata = useMemo(
() => ({
gitRevision: process.env.REACT_APP_GIT_SHA,
gitSha: process.env.REACT_APP_GIT_SHA ?? MISSING_MESSAGE,
gitRef: process.env.REACT_APP_GIT_REF ?? MISSING_MESSAGE,
}),
[]
);
Expand Down

0 comments on commit f79e139

Please sign in to comment.