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
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
|
|
|
name: GH Pages deploy
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches: [main]
|
|
|
|
paths:
|
|
|
|
- 'client/**/*'
|
|
|
|
pull_request:
|
|
|
|
branches: [main]
|
|
|
|
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-14 10:42:09 -04:00
|
|
|
- name: Set GITHUB_SHA_SHORT
|
|
|
|
run: echo "GITHUB_SHA_SHORT=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV
|
|
|
|
# If this is just a PR branch, put content in a hash directory. Otherwise, put it in "main"
|
|
|
|
- name: Set DESTINATION_FOLDER
|
|
|
|
run: echo "DESTINATION_FOLDER=${{ github.event.pull_request.merged == 'true' && 'main' || env.GITHUB_SHA_SHORT }}" >> $GITHUB_ENV
|
2021-05-25 12:07:45 -04:00
|
|
|
- name: Install
|
|
|
|
run: npm ci
|
|
|
|
- name: Build
|
|
|
|
run: npm run build --if-present
|
|
|
|
- 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-14 10:42:09 -04:00
|
|
|
- name: Set GITHUB_SHA_SHORT
|
|
|
|
run: echo "GITHUB_SHA_SHORT=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV
|
|
|
|
# If this is just a PR branch, put content in a hash directory. Otherwise, put it in "main"
|
|
|
|
- name: Set DESTINATION_FOLDER
|
|
|
|
run: echo "DESTINATION_FOLDER=${{ github.event.pull_request.merged == 'true' && 'main' || env.GITHUB_SHA_SHORT }}" >> $GITHUB_ENV
|
2021-06-07 11:57:46 -04:00
|
|
|
- name: Deploy to Github Pages
|
2021-05-25 12:07:45 -04:00
|
|
|
uses: JamesIves/github-pages-deploy-action@4.1.0
|
|
|
|
with:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
BRANCH: gh-pages # The branch the action should deploy to.
|
|
|
|
FOLDER: public # The folder the action should deploy.
|
2021-06-14 10:42:09 -04:00
|
|
|
TARGET-FOLDER: ${{env.DESTINATION_FOLDER}} # If we're on a PR branch, merge to PR folder
|
2021-06-07 11:57:46 -04:00
|
|
|
- name: Configure AWS Credentials
|
|
|
|
uses: aws-actions/configure-aws-credentials@v1
|
|
|
|
with:
|
|
|
|
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
|
|
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
|
|
aws-region: us-east-1
|
|
|
|
- name: Deploy to Geoplatform AWS
|
2021-06-14 10:42:09 -04:00
|
|
|
run: aws s3 sync ./public/ s3://usds-geoplatform-justice40-website/justice40-tool/${{env.DESTINATION_FOLDER}} --delete
|