Skip to content

Commit

Permalink
Merge pull request #182 from Eastern-Research-Group/staging
Browse files Browse the repository at this point in the history
Merging staging into main to support v1.0 of the application
  • Loading branch information
coobr01 authored May 23, 2022
2 parents 359a0d9 + 4207946 commit 9061b46
Show file tree
Hide file tree
Showing 66 changed files with 12,101 additions and 1,559 deletions.
23 changes: 23 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Change Agent Contact Information**
Capture as much information about the submitter as possible {Name, email, telephone, submission date/time, etc.}.

**Is this an emergency change request?**
Yes/No

**Does the request impact the security posture of the application/system? Please note, if so, the application's Information System Security Officer (ISSO) will need to be consulted about the change.**
Yes/No

**Describe the change**
Provide a clear and concise description of the change. Include information about how to reproduce any issue(s) including any software version(s) and device make/model(s) used.

**Additional context**
Add other context or screenshots about the change request here.
144 changes: 144 additions & 0 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# This is a basic workflow to help you get started with Actions

name: Dev Deploy

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the develop branch
push:
branches: [develop]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Set default working directory for all jobs to /app
defaults:
run:
working-directory: ./app

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Set environment variables
env:
APP_NAME: csb-dev
CLOUD_SPACE: dev
CF_ORG: epa-avert
CF_SPACE: csb-dev
CF_USER_DEV: ${{ secrets.CF_USER_DEV }}
CF_PASSWORD_DEV: ${{ secrets.CF_PASSWORD_DEV }}
SERVER_URL: https://app-dev.app.cloud.gov/csb
SERVER_BASE_PATH: /csb
SAML_LOGIN_URL: ${{ secrets.SAML_LOGIN_URL_DEV }}
SAML_LOGOUT_URL: ${{ secrets.SAML_LOGOUT_URL_DEV }}
SAML_ENTITY_ID: ${{ secrets.SAML_ENTITY_ID_DEV }}
SAML_IDP_CERT: ${{ secrets.SAML_IDP_CERT_DEV }}
SAML_PUBLIC_KEY: ${{ secrets.SAML_PUBLIC_KEY }}
# SAML_PRIVATE_KEY: ${{ secrets.SAML_PRIVATE_KEY }}
JWT_PUBLIC_KEY: ${{ secrets.JWT_PUBLIC_KEY }}
JWT_PRIVATE_KEY: ${{ secrets.JWT_PRIVATE_KEY }}
FORMIO_PKG_AUTH_TOKEN: ${{ secrets.FORMIO_PKG_AUTH_TOKEN }}
FORMIO_BASE_URL: ${{ secrets.FORMIO_BASE_URL }}
FORMIO_PROJECT_URL: ${{ secrets.FORMIO_PROJECT_URL }}
FORMIO_FORM_ID: ${{ secrets.FORMIO_FORM_ID }}
FORMIO_API_KEY: ${{ secrets.FORMIO_API_KEY }}
BAP_CLIENT_ID: ${{ secrets.BAP_CLIENT_ID }}
BAP_CLIENT_SECRET: ${{ secrets.BAP_CLIENT_SECRET }}
BAP_URL: ${{ secrets.BAP_URL }}
BAP_USER: ${{ secrets.BAP_USER }}
BAP_PASSWORD: ${{ secrets.BAP_PASSWORD }}
BAP_TABLE: ${{ secrets.BAP_TABLE }}
AWS_ACCESS_KEY_ID: ${{ secrets.S3_PUBLIC_ACCESS_KEY_ID_DEV }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_PUBLIC_SECRET_ACCESS_KEY_DEV }}
AWS_DEFAULT_REGION: ${{ secrets.S3_PUBLIC_REGION_DEV }}
S3_PUBLIC_BUCKET: ${{ secrets.S3_PUBLIC_BUCKET_DEV }}

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

# Set up node and npm
- uses: actions/setup-node@master

# Run front-end processes (install, lint, test, bundle)
- name: Cache node modules
uses: actions/cache@v2
with:
path: ~/client/.npm
key: v1-npm-client-deps-${{ hashFiles('**/client/package-lock.json') }}
restore-keys: v1-npm-client-deps-

- name: Add Formio private package repo auth token
run: echo "//pkg.form.io/:_authToken=${FORMIO_PKG_AUTH_TOKEN}" > .npmrc
working-directory: app/client

- name: Install front-end dependencies
run: npm install
working-directory: app/client

- name: Build front-end files and move to server
run: |
PUBLIC_URL="$SERVER_URL" \
REACT_APP_SERVER_BASE_PATH="$SERVER_BASE_PATH" \
REACT_APP_CLOUD_SPACE="$CLOUD_SPACE" \
REACT_APP_FORMIO_BASE_URL="$FORMIO_BASE_URL" \
REACT_APP_FORMIO_PROJECT_URL="$FORMIO_PROJECT_URL" \
npm run build
rm ../server/app/public/index.html
cd build
mv * ../../server/app/public
working-directory: app/client

# Run CloudFoundry/Cloud.gov deployment
- name: Set up Cloud Foundry CLI
run: |
curl -v -L -o cf-cli_amd64.deb 'https://cli.run.pivotal.io/stable?release=debian64&version=v7&source=github'
sudo dpkg -i cf-cli_amd64.deb
cf -v
cf api https://api.fr.cloud.gov
cf auth "$CF_USER_DEV" "$CF_PASSWORD_DEV"
cf target -o "$CF_ORG" -s "$CF_SPACE"
- name: Set application-level variables
run: |
cf set-env $APP_NAME "CLOUD_SPACE" "$CLOUD_SPACE" > /dev/null
cf set-env $APP_NAME "SERVER_URL" "$SERVER_URL" > /dev/null
cf set-env $APP_NAME "SERVER_BASE_PATH" "$SERVER_BASE_PATH" > /dev/null
cf set-env $APP_NAME "SAML_LOGIN_URL" "$SAML_LOGIN_URL" > /dev/null
cf set-env $APP_NAME "SAML_LOGOUT_URL" "$SAML_LOGOUT_URL" > /dev/null
cf set-env $APP_NAME "SAML_ENTITY_ID" "$SAML_ENTITY_ID" > /dev/null
cf set-env $APP_NAME "SAML_IDP_CERT" "$SAML_IDP_CERT" > /dev/null
cf set-env $APP_NAME "SAML_PUBLIC_KEY" "$SAML_PUBLIC_KEY" > /dev/null
cf set-env $APP_NAME "SAML_PRIVATE_KEY" "$SAML_PRIVATE_KEY" > /dev/null
cf set-env $APP_NAME "JWT_PUBLIC_KEY" "$JWT_PUBLIC_KEY" > /dev/null
cf set-env $APP_NAME "JWT_PRIVATE_KEY" "$JWT_PRIVATE_KEY" > /dev/null
cf set-env $APP_NAME "FORMIO_PROJECT_URL" "$FORMIO_PROJECT_URL" > /dev/null
cf set-env $APP_NAME "FORMIO_FORM_ID" "$FORMIO_FORM_ID" > /dev/null
cf set-env $APP_NAME "FORMIO_API_KEY" "$FORMIO_API_KEY" > /dev/null
cf set-env $APP_NAME "BAP_CLIENT_ID" "$BAP_CLIENT_ID" > /dev/null
cf set-env $APP_NAME "BAP_CLIENT_SECRET" "$BAP_CLIENT_SECRET" > /dev/null
cf set-env $APP_NAME "BAP_URL" "$BAP_URL" > /dev/null
cf set-env $APP_NAME "BAP_USER" "$BAP_USER" > /dev/null
cf set-env $APP_NAME "BAP_PASSWORD" "$BAP_PASSWORD" > /dev/null
cf set-env $APP_NAME "BAP_TABLE" "$BAP_TABLE" > /dev/null
cf set-env $APP_NAME "S3_PUBLIC_BUCKET" "$S3_PUBLIC_BUCKET" > /dev/null
cf set-env $APP_NAME "S3_PUBLIC_REGION" "$AWS_DEFAULT_REGION" > /dev/null
# Sync static content to public S3 bucket
- name: Sync static content to S3
run: aws s3 sync . s3://$S3_PUBLIC_BUCKET/content
working-directory: app/server/app/content

# Set CORS configuration for public S3 bucket
- name: Set S3 CORS configuration
run: aws s3api put-bucket-cors --bucket $S3_PUBLIC_BUCKET --cors-configuration file://s3CORS.json
working-directory: app/server/app/config

# Now that front-end is built in server/dist, only push server dir to Cloud.gov
- name: Deploy application to Cloud.gov
run: cf push $APP_NAME --strategy rolling -f ../manifest-dev.yml -p . -t 180
working-directory: app/server
144 changes: 144 additions & 0 deletions .github/workflows/staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# This is a basic workflow to help you get started with Actions

name: Staging Deploy

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the staging branch
push:
branches: [staging]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Set default working directory for all jobs to /app
defaults:
run:
working-directory: ./app

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Set environment variables
env:
APP_NAME: csb-staging
CLOUD_SPACE: staging
CF_ORG: epa-avert
CF_SPACE: csb-staging
CF_USER_STAGING: ${{ secrets.CF_USER_STAGING }}
CF_PASSWORD_STAGING: ${{ secrets.CF_PASSWORD_STAGING }}
SERVER_URL: https://app-stage.app.cloud.gov/csb
SERVER_BASE_PATH: /csb
SAML_LOGIN_URL: ${{ secrets.SAML_LOGIN_URL_STAGING }}
SAML_LOGOUT_URL: ${{ secrets.SAML_LOGOUT_URL_STAGING }}
SAML_ENTITY_ID: ${{ secrets.SAML_ENTITY_ID_STAGING }}
SAML_IDP_CERT: ${{ secrets.SAML_IDP_CERT_STAGING }}
SAML_PUBLIC_KEY: ${{ secrets.SAML_PUBLIC_KEY }}
SAML_PRIVATE_KEY: ${{ secrets.SAML_PRIVATE_KEY }}
JWT_PUBLIC_KEY: ${{ secrets.JWT_PUBLIC_KEY }}
JWT_PRIVATE_KEY: ${{ secrets.JWT_PRIVATE_KEY }}
FORMIO_PKG_AUTH_TOKEN: ${{ secrets.FORMIO_PKG_AUTH_TOKEN }}
FORMIO_BASE_URL: ${{ secrets.FORMIO_BASE_URL }}
FORMIO_PROJECT_URL: ${{ secrets.FORMIO_PROJECT_URL }}
FORMIO_FORM_ID: ${{ secrets.FORMIO_FORM_ID }}
FORMIO_API_KEY: ${{ secrets.FORMIO_API_KEY }}
BAP_CLIENT_ID: ${{ secrets.BAP_CLIENT_ID }}
BAP_CLIENT_SECRET: ${{ secrets.BAP_CLIENT_SECRET }}
BAP_URL: ${{ secrets.BAP_URL }}
BAP_USER: ${{ secrets.BAP_USER }}
BAP_PASSWORD: ${{ secrets.BAP_PASSWORD }}
BAP_TABLE: ${{ secrets.BAP_TABLE }}
AWS_ACCESS_KEY_ID: ${{ secrets.S3_PUBLIC_ACCESS_KEY_ID_STAGING }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_PUBLIC_SECRET_ACCESS_KEY_STAGING }}
AWS_DEFAULT_REGION: ${{ secrets.S3_PUBLIC_REGION_STAGING }}
S3_PUBLIC_BUCKET: ${{ secrets.S3_PUBLIC_BUCKET_STAGING }}

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2

# Set up node and npm
- uses: actions/setup-node@master

# Run front-end processes (install, lint, test, bundle)
- name: Cache node modules
uses: actions/cache@v2
with:
path: ~/client/.npm
key: v1-npm-client-deps-${{ hashFiles('**/client/package-lock.json') }}
restore-keys: v1-npm-client-deps-

- name: Add Formio private package repo auth token
run: echo "//pkg.form.io/:_authToken=${FORMIO_PKG_AUTH_TOKEN}" > .npmrc
working-directory: app/client

- name: Install front-end dependencies
run: npm install
working-directory: app/client

- name: Build front-end files and move to server
run: |
PUBLIC_URL="$SERVER_URL" \
REACT_APP_SERVER_BASE_PATH="$SERVER_BASE_PATH" \
REACT_APP_CLOUD_SPACE="$CLOUD_SPACE" \
REACT_APP_FORMIO_BASE_URL="$FORMIO_BASE_URL" \
REACT_APP_FORMIO_PROJECT_URL="$FORMIO_PROJECT_URL" \
npm run build
rm ../server/app/public/index.html
cd build
mv * ../../server/app/public
working-directory: app/client

# Run CloudFoundry/Cloud.gov deployment
- name: Set up Cloud Foundry CLI
run: |
curl -v -L -o cf-cli_amd64.deb 'https://cli.run.pivotal.io/stable?release=debian64&version=v7&source=github'
sudo dpkg -i cf-cli_amd64.deb
cf -v
cf api https://api.fr.cloud.gov
cf auth "$CF_USER_STAGING" "$CF_PASSWORD_STAGING"
cf target -o "$CF_ORG" -s "$CF_SPACE"
- name: Set application-level variables
run: |
cf set-env $APP_NAME "CLOUD_SPACE" "$CLOUD_SPACE" > /dev/null
cf set-env $APP_NAME "SERVER_URL" "$SERVER_URL" > /dev/null
cf set-env $APP_NAME "SERVER_BASE_PATH" "$SERVER_BASE_PATH" > /dev/null
cf set-env $APP_NAME "SAML_LOGIN_URL" "$SAML_LOGIN_URL" > /dev/null
cf set-env $APP_NAME "SAML_LOGOUT_URL" "$SAML_LOGOUT_URL" > /dev/null
cf set-env $APP_NAME "SAML_ENTITY_ID" "$SAML_ENTITY_ID" > /dev/null
cf set-env $APP_NAME "SAML_IDP_CERT" "$SAML_IDP_CERT" > /dev/null
cf set-env $APP_NAME "SAML_PUBLIC_KEY" "$SAML_PUBLIC_KEY" > /dev/null
cf set-env $APP_NAME "SAML_PRIVATE_KEY" "$SAML_PRIVATE_KEY" > /dev/null
cf set-env $APP_NAME "JWT_PUBLIC_KEY" "$JWT_PUBLIC_KEY" > /dev/null
cf set-env $APP_NAME "JWT_PRIVATE_KEY" "$JWT_PRIVATE_KEY" > /dev/null
cf set-env $APP_NAME "FORMIO_PROJECT_URL" "$FORMIO_PROJECT_URL" > /dev/null
cf set-env $APP_NAME "FORMIO_FORM_ID" "$FORMIO_FORM_ID" > /dev/null
cf set-env $APP_NAME "FORMIO_API_KEY" "$FORMIO_API_KEY" > /dev/null
cf set-env $APP_NAME "BAP_CLIENT_ID" "$BAP_CLIENT_ID" > /dev/null
cf set-env $APP_NAME "BAP_CLIENT_SECRET" "$BAP_CLIENT_SECRET" > /dev/null
cf set-env $APP_NAME "BAP_URL" "$BAP_URL" > /dev/null
cf set-env $APP_NAME "BAP_USER" "$BAP_USER" > /dev/null
cf set-env $APP_NAME "BAP_PASSWORD" "$BAP_PASSWORD" > /dev/null
cf set-env $APP_NAME "BAP_TABLE" "$BAP_TABLE" > /dev/null
cf set-env $APP_NAME "S3_PUBLIC_BUCKET" "$S3_PUBLIC_BUCKET" > /dev/null
cf set-env $APP_NAME "S3_PUBLIC_REGION" "$AWS_DEFAULT_REGION" > /dev/null
# Sync static content to public S3 bucket
- name: Sync static content to S3
run: aws s3 sync . s3://$S3_PUBLIC_BUCKET/content
working-directory: app/server/app/content

# Set CORS configuration for public S3 bucket
- name: Set S3 CORS configuration
run: aws s3api put-bucket-cors --bucket $S3_PUBLIC_BUCKET --cors-configuration file://s3CORS.json
working-directory: app/server/app/config

# Now that front-end is built in server/dist, only push server dir to Cloud.gov
- name: Deploy application to Cloud.gov
run: cf push $APP_NAME --strategy rolling -f ../manifest-staging.yml -p . -t 180
working-directory: app/server
1 change: 0 additions & 1 deletion app/client/.env.development

This file was deleted.

6 changes: 6 additions & 0 deletions app/client/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# NOTE: For local development, set `REACT_APP_FORMIO_BASE_URL` and
# `REACT_APP_FORMIO_PROJECT_URL` to the same values used in the server app's
# `FORMIO_BASE_URL` and `FORMIO_PROJECT_URL` env variables. When deployed, a
# GitHub Actions Workflow does this in the "build" npm script.
REACT_APP_FORMIO_BASE_URL=
REACT_APP_FORMIO_PROJECT_URL=
Loading

0 comments on commit 9061b46

Please sign in to comment.