Static Deploy to Github Pages (#73)

Addresses #58 , "As a member of the public, I want to see J40's website live on the internet, so that I know it's real!" - hosting on github pages for now as a temporary measure. This fix does NOT: 1) add .gov domain hosting, or 2) post to the geoplatform s3 bucket. This will need to happen in a subsequent fix. 

The changes made specifically to enable this for now:
* Adding github action to build, test, and deploy on pushes to client/
* Adding path prefix to build gh-pages at https://usds.github.io/justice40-tool/
* (Temporarily) pointing to fix branch for trussworks to enable SSR building
* Removing the workaround for the above bug in gatsby-node.js
* Setting build target to be 14.x due to version number limitations
* Adding gh-pages dependency, deploy action for manual deploy
* Force renaming J40header -> J40Header and J40footer -> J40Footer due to Linux case sensitivity
This commit is contained in:
Nat Hillard 2021-05-25 12:07:45 -04:00 committed by GitHub
parent da76d6b180
commit 16a9e67db0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 2465 additions and 22001 deletions

61
.github/workflows/node.js.yml vendored Normal file
View file

@ -0,0 +1,61 @@
# 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 }}
- name: Install
run: npm ci
- name: Build
run: npm run build --if-present
- name: Get directory contents
run: ls -la public
- name: Test
run: npm test
- 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
- name: Deploy 🚀
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.

View file

@ -12,6 +12,7 @@ module.exports = {
siteMetadata: {
title: "Justice40",
},
pathPrefix: "/justice40-tool",
plugins: [
{
resolve: 'gatsby-plugin-sass',

View file

@ -6,16 +6,4 @@ exports.onCreateWebpackConfig = ({ stage, loaders, actions }) => {
actions.setWebpackConfig({
devtool: 'eval-source-map',
});
if (stage === "build-html" || stage === "develop-html") {
actions.setWebpackConfig({
module: {
rules: [
{
test: /@trussworks\/react-uswds/,
use: loaders.null(),
},
],
}
})
}
}
}

24384
client/package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -10,9 +10,10 @@
"scripts": {
"develop": "gatsby develop",
"start": "gatsby develop",
"build": "gatsby build",
"build": "gatsby build --prefix-paths",
"serve": "gatsby serve",
"clean": "gatsby clean",
"deploy": "gatsby build --prefix-paths && gh-pages -d public",
"intl:extract": "formatjs extract 'src/(pages|components)/*.tsx' --out-file src/intl/en.json",
"intl:compile": "formatjs compile src/intl/en.json --ast --out-file compiled-lang/en.json"
},
@ -24,11 +25,12 @@
"gatsby-cli": "^3.5.0",
"gatsby-plugin-intl": "^0.3.3",
"gatsby-plugin-sass": "^4.5.0",
"gh-pages": "^3.2.0",
"sass": "^1.33.0",
"sass-loader": "^11.1.1"
},
"dependencies": {
"@trussworks/react-uswds": "^1.17.0",
"@trussworks/react-uswds": "trussworks/react-uswds#kh-serverside-rendering-fix-1250",
"gatsby": "^3.4.1",
"react": "^17.0.1",
"react-dom": "^17.0.1"