Skip to content

Merge pull request #207 from Eastern-Research-Group/bugfix/duplicate-… #363

Merge pull request #207 from Eastern-Research-Group/bugfix/duplicate-…

Merge pull request #207 from Eastern-Research-Group/bugfix/duplicate-… #363

Workflow file for this run

# This is a basic workflow to help you get started with Actions
name: Dev Deploy
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch branches: [ develop ]
push:
branches: [develop]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
changes:
# The type of runner that the job will run on
runs-on: ubuntu-latest
environment: dev
outputs:
workflows: ${{ steps.filter.outputs.workflows }}
app: ${{ steps.filter.outputs.app }}
etl: ${{ steps.filter.outputs.etl }}
# 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@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
workflows:
- '.github/workflows/dev.yml'
app:
- 'app/**'
etl:
- 'etl/**'
app:
# Check if this folder has any changes
needs: changes
if: ${{
needs.changes.outputs.app == 'true' ||
needs.changes.outputs.workflows == 'true' }}
# The type of runner that the job will run on
runs-on: ubuntu-latest
environment: dev
# Set environment variables
env:
APP_NAME: expert-query-dev
CLOUD_SPACE: dev
CF_ORG: ${{ secrets.CF_ORG }}
CF_SPACE: ${{ secrets.CF_SPACE_DEV }}
CF_STACK: cflinuxfs4
CF_USER_DEV: ${{ secrets.CF_USER_DEV }}
CF_PASSWORD_DEV: ${{ secrets.CF_PASSWORD_DEV }}
CF_S3_PUB_ACCESS_KEY: ${{ secrets.CF_DEV_S3_PUB_ACCESS_KEY }}
CF_S3_PUB_BUCKET_ID: ${{ secrets.CF_DEV_S3_PUB_BUCKET_ID }}
CF_S3_PUB_REGION: ${{ secrets.CF_DEV_S3_PUB_REGION }}
CF_S3_PUB_SECRET_KEY: ${{ secrets.CF_DEV_S3_PUB_SECRET_KEY }}
CF_S3_PRIV_ACCESS_KEY: ${{ secrets.CF_DEV_S3_PRIV_ACCESS_KEY }}
CF_S3_PRIV_BUCKET_ID: ${{ secrets.CF_DEV_S3_PRIV_BUCKET_ID }}
CF_S3_PRIV_REGION: ${{ secrets.CF_DEV_S3_PRIV_REGION }}
CF_S3_PRIV_SECRET_KEY: ${{ secrets.CF_DEV_S3_PRIV_SECRET_KEY }}
DB_POOL_MAX: 20
DB_POOL_MIN: 5
DB_SSL: true
DB_NAME: ${{ secrets.DB_NAME_DEV }}
DB_PASSWORD: ${{ secrets.EQ_PASSWORD_DEV }}
DB_USERNAME: ${{ secrets.EQ_USER_DEV }}
EQ_BASIC_USER_NAME: ${{ secrets.EQ_BASIC_USER_NAME }}
EQ_BASIC_USER_PWD: ${{ secrets.EQ_BASIC_USER_PWD }}
EQ_SECRET: ${{ secrets.EQ_SECRET_DEV }}
MAX_QUERY_SIZE: 1000000
SERVER_BASE_PATH: /expertquery
SERVER_URL: https://owapps-dev.app.cloud.gov/expertquery
SKIP_DOCUMENTS_TEXT_QA: true
STREAM_BATCH_SIZE: 2000
STREAM_HIGH_WATER_MARK: 10000
# 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@v4
# Set up node and npm
- uses: actions/setup-node@v4
with:
node-version: "20"
# Run front-end processes (install, lint, test, bundle)
- name: Cache node modules
uses: actions/cache@v4
with:
path: ~/client/.npm
key: v1-npm-client-deps-${{ hashFiles('**/client/package-lock.json') }}
restore-keys: v1-npm-client-deps-
- name: Install front-end dependencies
run: |
npm install --legacy-peer-deps
npx gulp init
working-directory: app/client
- name: Build front-end files and move to server
run: |
VITE_SERVER_BASE_PATH="$SERVER_BASE_PATH" \
VITE_CLOUD_SPACE="$CLOUD_SPACE" \
npm run build
cd build
cp -r * ../../server/app/public
rm -rf *
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://packages.cloudfoundry.org/stable?release=debian64&version=8.8.3&source=github-rel'
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 "CF_S3_PUB_ACCESS_KEY" "$CF_S3_PUB_ACCESS_KEY" > /dev/null
cf set-env $APP_NAME "CF_S3_PUB_BUCKET_ID" "$CF_S3_PUB_BUCKET_ID" > /dev/null
cf set-env $APP_NAME "CF_S3_PUB_REGION" "$CF_S3_PUB_REGION" > /dev/null
cf set-env $APP_NAME "CF_S3_PUB_SECRET_KEY" "$CF_S3_PUB_SECRET_KEY" > /dev/null
cf set-env $APP_NAME "CF_S3_PRIV_ACCESS_KEY" "$CF_S3_PRIV_ACCESS_KEY" > /dev/null
cf set-env $APP_NAME "CF_S3_PRIV_BUCKET_ID" "$CF_S3_PRIV_BUCKET_ID" > /dev/null
cf set-env $APP_NAME "CF_S3_PRIV_REGION" "$CF_S3_PRIV_REGION" > /dev/null
cf set-env $APP_NAME "CF_S3_PRIV_SECRET_KEY" "$CF_S3_PRIV_SECRET_KEY" > /dev/null
cf set-env $APP_NAME "DB_POOL_MAX" "$DB_POOL_MAX" > /dev/null
cf set-env $APP_NAME "DB_POOL_MIN" "$DB_POOL_MIN" > /dev/null
cf set-env $APP_NAME "DB_SSL" "$DB_SSL" > /dev/null
cf set-env $APP_NAME "DB_NAME" "$DB_NAME" > /dev/null
cf set-env $APP_NAME "DB_PASSWORD" "$DB_PASSWORD" > /dev/null
cf set-env $APP_NAME "DB_USERNAME" "$DB_USERNAME" > /dev/null
cf set-env $APP_NAME "EQ_BASIC_USER_NAME" "$EQ_BASIC_USER_NAME" > /dev/null
cf set-env $APP_NAME "EQ_BASIC_USER_PWD" "$EQ_BASIC_USER_PWD" > /dev/null
cf set-env $APP_NAME "EQ_SECRET" "$EQ_SECRET" > /dev/null
cf set-env $APP_NAME "MAX_QUERY_SIZE" "$MAX_QUERY_SIZE" > /dev/null
cf set-env $APP_NAME "PUBLIC_URL" "$SERVER_URL" > /dev/null
cf set-env $APP_NAME "SERVER_BASE_PATH" "$SERVER_BASE_PATH" > /dev/null
cf set-env $APP_NAME "SERVER_URL" "$SERVER_URL" > /dev/null
cf set-env $APP_NAME "SKIP_DOCUMENTS_TEXT_QA" "$SKIP_DOCUMENTS_TEXT_QA" > /dev/null
cf set-env $APP_NAME "STREAM_BATCH_SIZE" "$STREAM_BATCH_SIZE" > /dev/null
cf set-env $APP_NAME "STREAM_HIGH_WATER_MARK" "$STREAM_HIGH_WATER_MARK" > /dev/null
cf set-env $APP_NAME "TZ" "America/New_York" > /dev/null
- name: Configure Public AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ env.CF_S3_PUB_ACCESS_KEY }}
aws-secret-access-key: ${{ env.CF_S3_PUB_SECRET_KEY }}
aws-region: ${{ env.CF_S3_PUB_REGION }}
# Sync static content to public S3 bucket
- name: Sync static content to S3
run: aws s3 sync . s3://$CF_S3_PUB_BUCKET_ID/content
working-directory: app/server/app/content
# Set CORS configuration for public S3 bucket
- name: Set public S3 CORS configuration
run: aws s3api put-bucket-cors --bucket $CF_S3_PUB_BUCKET_ID --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 -s $CF_STACK
working-directory: app/server
etl:
# Check if this folder has any changes
needs: changes
if: ${{
needs.changes.outputs.etl == 'true' ||
needs.changes.outputs.workflows == 'true' }}
# The type of runner that the job will run on
runs-on: ubuntu-latest
environment: dev
# Set environment variables
env:
APP_NAME: expert-query-etl-dev
CF_ORG: ${{ secrets.CF_ORG }}
CF_SPACE: ${{ secrets.CF_SPACE_DEV }}
CF_STACK: cflinuxfs4
CF_USER_DEV: ${{ secrets.CF_USER_DEV }}
CF_PASSWORD_DEV: ${{ secrets.CF_PASSWORD_DEV }}
CF_S3_PUB_ACCESS_KEY: ${{ secrets.CF_DEV_S3_PUB_ACCESS_KEY }}
CF_S3_PUB_BUCKET_ID: ${{ secrets.CF_DEV_S3_PUB_BUCKET_ID }}
CF_S3_PUB_REGION: ${{ secrets.CF_DEV_S3_PUB_REGION }}
CF_S3_PUB_SECRET_KEY: ${{ secrets.CF_DEV_S3_PUB_SECRET_KEY }}
CF_S3_PRIV_ACCESS_KEY: ${{ secrets.CF_DEV_S3_PRIV_ACCESS_KEY }}
CF_S3_PRIV_BUCKET_ID: ${{ secrets.CF_DEV_S3_PRIV_BUCKET_ID }}
CF_S3_PRIV_REGION: ${{ secrets.CF_DEV_S3_PRIV_REGION }}
CF_S3_PRIV_SECRET_KEY: ${{ secrets.CF_DEV_S3_PRIV_SECRET_KEY }}
DB_NAME: ${{ secrets.DB_NAME_DEV }}
DB_SSL: true
EQ_PASSWORD: ${{ secrets.EQ_PASSWORD_DEV }}
EQ_USERNAME: ${{ secrets.EQ_USER_DEV }}
GLOSSARY_AUTH: ${{ secrets.GLOSSARY_AUTH }}
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
# Set up node and npm
- uses: actions/setup-node@v4
with:
node-version: "20"
# Run CloudFoundry/Cloud.gov deployment
- name: Set up Cloud Foundry CLI
run: |
curl -v -L -o cf-cli_amd64.deb 'https://packages.cloudfoundry.org/stable?release=debian64&version=8.8.3&source=github-rel'
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 "CF_S3_PUB_ACCESS_KEY" "$CF_S3_PUB_ACCESS_KEY" > /dev/null
cf set-env $APP_NAME "CF_S3_PUB_BUCKET_ID" "$CF_S3_PUB_BUCKET_ID" > /dev/null
cf set-env $APP_NAME "CF_S3_PUB_REGION" "$CF_S3_PUB_REGION" > /dev/null
cf set-env $APP_NAME "CF_S3_PUB_SECRET_KEY" "$CF_S3_PUB_SECRET_KEY" > /dev/null
cf set-env $APP_NAME "CF_S3_PRIV_ACCESS_KEY" "$CF_S3_PRIV_ACCESS_KEY" > /dev/null
cf set-env $APP_NAME "CF_S3_PRIV_BUCKET_ID" "$CF_S3_PRIV_BUCKET_ID" > /dev/null
cf set-env $APP_NAME "CF_S3_PRIV_REGION" "$CF_S3_PRIV_REGION" > /dev/null
cf set-env $APP_NAME "CF_S3_PRIV_SECRET_KEY" "$CF_S3_PRIV_SECRET_KEY" > /dev/null
cf set-env $APP_NAME "DB_NAME" "$DB_NAME" > /dev/null
cf set-env $APP_NAME "DB_SSL" "$DB_SSL" > /dev/null
cf set-env $APP_NAME "EQ_USERNAME" "$EQ_USERNAME" > /dev/null
cf set-env $APP_NAME "EQ_PASSWORD" "$EQ_PASSWORD" > /dev/null
cf set-env $APP_NAME "GLOSSARY_AUTH" "$GLOSSARY_AUTH" > /dev/null
cf set-env $APP_NAME "TZ" "America/New_York" > /dev/null
- name: Configure Private AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ env.CF_S3_PRIV_ACCESS_KEY }}
aws-secret-access-key: ${{ env.CF_S3_PRIV_SECRET_KEY }}
aws-region: ${{ env.CF_S3_PRIV_REGION }}
# Sync private static content to private S3 bucket
- name: Sync private static content to S3
run: aws s3 sync . s3://$CF_S3_PRIV_BUCKET_ID/content-private
working-directory: etl/app/content-private
# Set CORS configuration for private S3 bucket
- name: Set private S3 CORS configuration
run: aws s3api put-bucket-cors --bucket $CF_S3_PRIV_BUCKET_ID --cors-configuration file://s3CORS.json
working-directory: etl/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 -s $CF_STACK
working-directory: etl