Skip to content

Commit

Permalink
Merge 1d2d6b7 into c4440d6
Browse files Browse the repository at this point in the history
  • Loading branch information
macfarlandian committed Feb 6, 2021
2 parents c4440d6 + 1d2d6b7 commit 0e47713
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 1 deletion.
72 changes: 72 additions & 0 deletions .github/workflows/spotlight-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Spotlight Staging Deploy
on:
push:
branches:
- master
paths:
- "spotlight-client/**"
defaults:
run:
working-directory: spotlight-client

jobs:
build:
name: Build frontend
runs-on: ubuntu-latest
environment: staging

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: "12.x"
- uses: c-hive/gha-yarn-cache@v1
- name: Install dependencies
run: yarn install --frozen-lockfile
- name: Build
# in lieu of build-staging, which consumes a .env that is not available in CI,
# we configure the build for staging here
env:
REACT_APP_AUTH_ENABLED: true
REACT_APP_AUTH_ENV: development
REACT_APP_API_URL: ${{ secrets.REACT_APP_API_URL }}
run: yarn build
- name: Store build artifact
uses: actions/upload-artifact@v2
with:
name: build
path: spotlight-client/build
if-no-files-found: error
deploy:
name: Deploy frontend
needs: build
runs-on: ubuntu-latest
environment: staging
steps:
- uses: actions/checkout@v2
- name: Download build artifact
uses: actions/download-artifact@v2
with:
name: build
path: spotlight-client/build
- name: Wait on lint
uses: lewagon/wait-on-check-action@v0.2
with:
ref: ${{ github.sha }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
check-name: Lint Spotlight Client
wait-interval: 10 # seconds
- name: Wait on tests
uses: lewagon/wait-on-check-action@v0.2
with:
ref: ${{ github.sha }}
repo-token: ${{ secrets.GITHUB_TOKEN }}
check-name: Test Spotlight Client
wait-interval: 10 # seconds
- name: Deploy to Firebase
uses: w9jds/firebase-action@v2
env:
GCP_SA_KEY: ${{ secrets.FIREBASE_SERVICE_ACCT_KEY }}
PROJECT_PATH: ./spotlight-client
with:
args: deploy -P staging
6 changes: 5 additions & 1 deletion spotlight-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Expected environment variables include:

The build process, as described below, ensures that the proper values are compiled and included in the static bundle at build time, for the right environment.

The necessary environment variables **must** also be added to the `spotlight-staging` Github CI workflow in `/.github/workflows`; this workflow carries out automated staging deployments. It does not have access to the `.env` files used by your local environment. (Adding or updating secrets requires admin privileges on this repository; if you don't have those, reach out to a Recidiviz staff member for help.)

### Running the application locally

`yarn dev` will start a Webpack development server on port `3000` and open the homepage in your browser.
Expand All @@ -62,7 +64,9 @@ Once you have the required permissions, you can set up your environment for depl

### Deploying to Staging

To generate a staging build, invoke the following yarn script: `yarn build-staging`. This will include the appropriate environment variables from `.env.development`. Each time this is run, the `/build` directory will be wiped clean.
All commits to `master` are automatically deployed to the staging environment by the `spotlight-staging` Github CI workflow, keeping staging up to date as pull requests are merged. (It thus bears mentioning that you should not merge anything to `master` that isn't immediately deployable!)

You can also generate and deploy staging builds locally as needed. To generate a staging build, invoke the following yarn script: `yarn build-staging`. This will include the appropriate environment variables from `.env.development`. Each time this is run, the `/build` directory will be wiped clean.

You should then test this locally by running `firebase serve`: it will run the staging build locally, pointed to the staging API backend. (Note that this means you will have to deploy the backend to staging first if your build requires unreleased backend features.)

Expand Down

0 comments on commit 0e47713

Please sign in to comment.