diff --git a/.github/workflows/deploy_main.yml b/.github/workflows/deploy_main.yml new file mode 100644 index 00000000..6e9401ae --- /dev/null +++ b/.github/workflows/deploy_main.yml @@ -0,0 +1,120 @@ +# 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: Deploy of main (AWS CDN) +on: + pull_request: + types: [closed] + branches: [main] + paths: + - "client/**/*" +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 }} + # If this is just a PR branch, put content in a hash directory. Otherwise, put it in "main" + # This variable is used by gatsby-config.js to set a prefixPath + - name: Set DESTINATION_FOLDER for main + # if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true + run: | + echo "DESTINATION_FOLDER=main" >> $GITHUB_ENV + # - name: Set DESTINATION_FOLDER for branch + # if: github.event.pull_request.merged != true + # run: | + # echo "DESTINATION_FOLDER=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV + - name: Install + run: npm ci + - name: Build + run: npm run build --if-present + env: + DATA_SOURCE: development + - name: Get directory contents + run: ls -la public + - name: Lint + run: npm run lint + # Disabling for now due to jsonlint - TODO: put this back + # - name: License Check + # run: npm run licenses + - name: Test + run: npm test + - name: Check for security vulnerabilities + run: npm audit --production + - 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 + # If this is just a PR branch, put content in a hash directory. Otherwise, put it in "main" + - name: Set DESTINATION_FOLDER for main + # if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true + run: | + echo "DESTINATION_FOLDER=main" >> $GITHUB_ENV + # - name: Set DESTINATION_FOLDER for branch + # if: github.event.pull_request.merged != true + # run: | + # echo "DESTINATION_FOLDER=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV + # - name: Deploy to Github Pages + # uses: JamesIves/github-pages-deploy-action@4.1.0 + # with: + # BRANCH: gh-pages # The branch the action should deploy to. + # FOLDER: public # The folder the action should deploy. + # TARGET-FOLDER: ${{env.DESTINATION_FOLDER}} # If we're on a PR branch, merge to PR folder + # CLEAN: true + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.CLIENT_DEV_AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.CLIENT_DEV_AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-1 + - name: Deploy to Geoplatform AWS + run: aws s3 sync ./public/ s3://usds-geoplatform-justice40-website/justice40-tool/${{env.DESTINATION_FOLDER}} --acl public-read --delete + - name: Invalidate cache on AWS CDNs + uses: chetan/invalidate-cloudfront-action@master + env: + DISTRIBUTION: "ED03LPVC4OXSW" # TODO: set this as ENV var above + 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 }} + - name: Update PR with deployed URL + uses: mshick/add-pr-comment@v1 + # if: (github.event_name == 'pull_request' && github.event.action == 'opened') || github.event_name == 'push' # Only comment if the PR has been opened or a push has updated it + with: + message: | + **🚢 PR Deployed! 🚢** + Find it here: https://d2zjid6n5ja2pt.cloudfront.net/justice40-tool/${{env.DESTINATION_FOLDER}}/en/cejst/ ! + repo-token: ${{ secrets.GITHUB_TOKEN }} + repo-token-user-login: "github-actions[bot]" # The user.login for temporary GitHub tokens + allow-repeats: false # This is the default + - name: Printing deployment URLs + run: | + echo "Github pages: https://usds.github.io/justice40-tool/$DESTINATION_FOLDER/en" + echo "Standard S3 bucket version (http only) : http://usds-geoplatform-justice40-website.s3-website-us-east-1.amazonaws.com/justice40-tool/$DESTINATION_FOLDER/en" + echo "Cloudfront https: https://d2zjid6n5ja2pt.cloudfront.net/justice40-tool/$DESTINATION_FOLDER/en" diff --git a/.github/workflows/build_deploy.yml b/.github/workflows/deploy_staging.yml similarity index 73% rename from .github/workflows/build_deploy.yml rename to .github/workflows/deploy_staging.yml index 350cca78..435e2ab3 100644 --- a/.github/workflows/build_deploy.yml +++ b/.github/workflows/deploy_staging.yml @@ -1,22 +1,18 @@ # 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 +name: Deploy to staging (GH & S3) on: pull_request: - types: [ closed, opened ] branches: [main] paths: - - 'client/**/*' - push: - branches: - - '*' # Run on all updates to PR branches - - '!main' # Do not run on pushes to main - paths: - - 'client/**/*' + - "client/**/*" + # push: + # branches: + # - '*' # Run on all updates to PR branches + # - '!main' # Do not run on pushes to main + # paths: + # - 'client/**/*' jobs: build: runs-on: ubuntu-latest @@ -34,12 +30,12 @@ jobs: node-version: ${{ matrix.node-version }} # If this is just a PR branch, put content in a hash directory. Otherwise, put it in "main" # This variable is used by gatsby-config.js to set a prefixPath - - name: Set DESTINATION_FOLDER for main - if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true - run: | - echo "DESTINATION_FOLDER=main" >> $GITHUB_ENV + # - name: Set DESTINATION_FOLDER for main + # if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true + # run: | + # echo "DESTINATION_FOLDER=main" >> $GITHUB_ENV - name: Set DESTINATION_FOLDER for branch - if: github.event.pull_request.merged != true + # if: github.event.pull_request.merged != true run: | echo "DESTINATION_FOLDER=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV - name: Install @@ -78,12 +74,12 @@ jobs: name: J40Static path: ./public # If this is just a PR branch, put content in a hash directory. Otherwise, put it in "main" - - name: Set DESTINATION_FOLDER for main - if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true - run: | - echo "DESTINATION_FOLDER=main" >> $GITHUB_ENV + # - name: Set DESTINATION_FOLDER for main + # if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true + # run: | + # echo "DESTINATION_FOLDER=main" >> $GITHUB_ENV - name: Set DESTINATION_FOLDER for branch - if: github.event.pull_request.merged != true + # if: github.event.pull_request.merged != true run: | echo "DESTINATION_FOLDER=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV - name: Deploy to Github Pages @@ -103,13 +99,14 @@ jobs: run: aws s3 sync ./public/ s3://usds-geoplatform-justice40-website/justice40-tool/${{env.DESTINATION_FOLDER}} --acl public-read --delete - name: Update PR with deployed URL uses: mshick/add-pr-comment@v1 - if: (github.event_name == 'pull_request' && github.event.action == 'opened') || github.event_name == 'push' # Only comment if the PR has been opened or a push has updated it + # if: (github.event_name == 'pull_request' && github.event.action == 'opened') || github.event_name == 'push' # Only comment if the PR has been opened or a push has updated it with: + # Deploy to S3 for the staging URL message: | - **🚢 PR Deployed! 🚢** - Find it here: https://d2zjid6n5ja2pt.cloudfront.net/justice40-tool/${{env.DESTINATION_FOLDER}}/en/cejst/ ! + **🚢 PR Deployed! 🚢** + Find it here: http://usds-geoplatform-justice40-website.s3-website-us-east-1.amazonaws.com/justice40-tool/${{env.DESTINATION_FOLDER}}/en/cejst/ ! repo-token: ${{ secrets.GITHUB_TOKEN }} - repo-token-user-login: 'github-actions[bot]' # The user.login for temporary GitHub tokens + repo-token-user-login: "github-actions[bot]" # The user.login for temporary GitHub tokens allow-repeats: false # This is the default - name: Printing deployment URLs run: | diff --git a/client/src/components/DatasetContainer/index.tsx b/client/src/components/DatasetContainer/index.tsx index 87b0d05e..47d66365 100644 --- a/client/src/components/DatasetContainer/index.tsx +++ b/client/src/components/DatasetContainer/index.tsx @@ -72,6 +72,7 @@ const DatasetContainer = () => { }, }); + // JSX return value again trigger return (