2021-05-25 12:07:45 -04:00
|
|
|
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
|
|
|
|
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
|
|
|
|
|
2021-10-14 15:28:25 -07:00
|
|
|
name: Deploy prod
|
2021-05-25 12:07:45 -04:00
|
|
|
on:
|
2022-02-02 16:44:10 -05:00
|
|
|
push:
|
2021-05-25 12:07:45 -04:00
|
|
|
branches: [main]
|
|
|
|
paths:
|
2021-09-10 11:05:35 -07:00
|
|
|
- "client/**/*"
|
2021-10-07 20:38:37 -04:00
|
|
|
env:
|
2022-02-02 17:21:10 -05:00
|
|
|
PR_NUMBER: ${{ github.event.number }}
|
2021-10-07 20:38:37 -04:00
|
|
|
WEB_CDN_ID: E27WCOZZ03KIBX
|
2021-05-25 12:07:45 -04:00
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
defaults:
|
|
|
|
run:
|
|
|
|
working-directory: client
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
node-version: [14.x]
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
- name: Use Node.js ${{ matrix.node-version }}
|
|
|
|
uses: actions/setup-node@v2
|
|
|
|
with:
|
|
|
|
node-version: ${{ matrix.node-version }}
|
2021-06-28 10:59:08 -04:00
|
|
|
- name: Set DESTINATION_FOLDER for main
|
|
|
|
run: |
|
|
|
|
echo "DESTINATION_FOLDER=main" >> $GITHUB_ENV
|
2021-05-25 12:07:45 -04:00
|
|
|
- name: Install
|
|
|
|
run: npm ci
|
|
|
|
- name: Build
|
|
|
|
run: npm run build --if-present
|
2021-09-07 10:35:11 -07:00
|
|
|
env:
|
2021-10-04 08:43:33 -07:00
|
|
|
# See the client readme for more info on environment variables:
|
|
|
|
# https://github.com/usds/justice40-tool/blob/main/client/README.md
|
|
|
|
DATA_SOURCE: cdn
|
|
|
|
# TODO: Update main URL when either is back up
|
2022-01-21 12:24:27 -05:00
|
|
|
SITE_URL: "${{ secrets.PROD_SITE_URL }}"
|
2022-01-18 15:16:33 -05:00
|
|
|
MAPBOX_STYLES_READ_TOKEN: "${{ secrets.MAPBOX_STYLES_READ_TOKEN }}"
|
2021-05-25 12:07:45 -04:00
|
|
|
- name: Get directory contents
|
|
|
|
run: ls -la public
|
2021-05-25 16:21:21 -04:00
|
|
|
- name: Lint
|
|
|
|
run: npm run lint
|
2021-06-16 18:16:49 -04:00
|
|
|
# Disabling for now due to jsonlint - TODO: put this back
|
|
|
|
# - name: License Check
|
|
|
|
# run: npm run licenses
|
2021-05-25 12:07:45 -04:00
|
|
|
- name: Test
|
|
|
|
run: npm test
|
2021-06-02 13:21:23 -04:00
|
|
|
- name: Check for security vulnerabilities
|
|
|
|
run: npm audit --production
|
2021-05-25 12:07:45 -04:00
|
|
|
- name: Upload Artifact
|
|
|
|
uses: actions/upload-artifact@v2
|
|
|
|
with:
|
|
|
|
name: J40Static
|
|
|
|
# Upload-artifact does not support the default working directory
|
|
|
|
# See more: https://github.com/actions/upload-artifact/issues/87
|
|
|
|
path: ./client/public
|
|
|
|
deploy:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: build
|
|
|
|
steps:
|
|
|
|
- name: Checkout source
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Download Artifacts
|
|
|
|
uses: actions/download-artifact@v2
|
|
|
|
with:
|
|
|
|
name: J40Static
|
|
|
|
path: ./public
|
2021-06-28 10:59:08 -04:00
|
|
|
- name: Set DESTINATION_FOLDER for main
|
|
|
|
run: |
|
|
|
|
echo "DESTINATION_FOLDER=main" >> $GITHUB_ENV
|
2021-06-07 11:57:46 -04:00
|
|
|
- name: Configure AWS Credentials
|
|
|
|
uses: aws-actions/configure-aws-credentials@v1
|
|
|
|
with:
|
2021-08-16 14:25:34 -04:00
|
|
|
aws-access-key-id: ${{ secrets.CLIENT_DEV_AWS_ACCESS_KEY_ID }}
|
2021-08-16 14:47:15 -04:00
|
|
|
aws-secret-access-key: ${{ secrets.CLIENT_DEV_AWS_SECRET_ACCESS_KEY }}
|
2021-06-07 11:57:46 -04:00
|
|
|
aws-region: us-east-1
|
|
|
|
- name: Deploy to Geoplatform AWS
|
2021-08-12 14:17:25 -04:00
|
|
|
run: aws s3 sync ./public/ s3://usds-geoplatform-justice40-website/justice40-tool/${{env.DESTINATION_FOLDER}} --acl public-read --delete
|
2021-09-10 13:17:30 -07:00
|
|
|
- name: Invalidate cache on AWS CDNs
|
|
|
|
uses: chetan/invalidate-cloudfront-action@master
|
|
|
|
env:
|
2021-10-07 20:38:37 -04:00
|
|
|
DISTRIBUTION: ${{env.WEB_CDN_ID}}
|
2021-09-10 13:17:30 -07:00
|
|
|
PATHS: "/*"
|
|
|
|
AWS_REGION: "us-east-1"
|
|
|
|
AWS_ACCESS_KEY_ID: ${{ secrets.CLIENT_DEV_AWS_ACCESS_KEY_ID }}
|
|
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.CLIENT_DEV_AWS_SECRET_ACCESS_KEY }}
|
2021-07-27 12:37:17 -04:00
|
|
|
- name: Update PR with deployed URL
|
|
|
|
uses: mshick/add-pr-comment@v1
|
|
|
|
with:
|
|
|
|
message: |
|
|
|
|
**🚢 PR Deployed! 🚢**
|
2021-10-04 08:43:33 -07:00
|
|
|
Find it here: https://d29zfl8cj7y1zf.cloudfront.net/ !
|
2021-07-27 12:37:17 -04:00
|
|
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
2021-09-10 11:05:35 -07:00
|
|
|
repo-token-user-login: "github-actions[bot]" # The user.login for temporary GitHub tokens
|
2021-07-27 12:37:17 -04:00
|
|
|
allow-repeats: false # This is the default
|
|
|
|
- name: Printing deployment URLs
|
|
|
|
run: |
|
2021-10-04 08:43:33 -07:00
|
|
|
echo "Geoplatform official site (may or may not be up): https://screeningtool.geoplatform.gov/"
|
|
|
|
echo "The Cloudfront behind this official site: https://d29zfl8cj7y1zf.cloudfront.net/"
|
2021-07-27 12:37:17 -04:00
|
|
|
echo "Github pages: https://usds.github.io/justice40-tool/$DESTINATION_FOLDER/en"
|
2021-10-04 08:43:33 -07:00
|
|
|
echo "The origin S3 bucket (http only) : http://usds-geoplatform-justice40-website.s3-website-us-east-1.amazonaws.com/justice40-tool/$DESTINATION_FOLDER/en"
|