Skip to content

Commit

Permalink
Merge pull request #27 from NASA-IMPACT/develop
Browse files Browse the repository at this point in the history
Staging to production
  • Loading branch information
hanbyul-here authored Jun 6, 2022
2 parents 9692580 + fa06fc1 commit ca99c42
Show file tree
Hide file tree
Showing 62 changed files with 2,998 additions and 114 deletions.
2 changes: 1 addition & 1 deletion .delta/ui
Submodule ui updated from 2e8548 to 3ef9c4
23 changes: 23 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Title of the application shown on the header and wherever the name is needed.
APP_TITLE=Dashboard Delta

# Short description used in meta tags. It shows up when the app url is shared.
APP_DESCRIPTION=Earth changing dashboard

# Email to reach out when an error occurs or the users have questions.
APP_CONTACT_EMAIL=[email protected]

# Endpoint for the Tiler server. No trailing slash.
API_RASTER_ENDPOINT='https://staging-raster.delta-backend.com'

# Endpoint for the STAC server. No trailing slash.
API_STAC_ENDPOINT='https://staging-stac.delta-backend.com'

# The mapbox public token obtained from your account
MAPBOX_TOKEN='pk.eyJ1IjoiY292aWQtbmFzYSIsImEiOiJja2F6eHBobTUwMzVzMzFueGJuczF6ZzdhIn0.8va1fkyaWgM57_gZ2rBMMg'

MAPBOX_STYLE_URL='mapbox://styles/covid-nasa/ckb01h6f10bn81iqg98ne0i2y'

# If the app is being served in from a subfolder, the domain url must be set.
# For example, if the app is served from /mysite:
# PUBLIC_URL=http://example.com/mysite
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE/configure-xx-story-for-the-dashboard.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: Configure XX story for the dashboard
about: High-level steps for configuring a story for the dashboard
title: Configure XX story for the dashboard
labels: 'stories'
assignees: ''

---

- [ ] Read the story
- [ ] Make sure all datasets required have been published
- [ ] Configure all datasets in delta-config ([Content documentation](../../docs/CONTENT.md) is a good place to start)
- [ ] Configure story content in delta-config and check preview (dependency on running the dashboard locally or https://github.com/NASA-IMPACT/delta-config/issues/12)
- [ ] Preview story with story tellers
95 changes: 95 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# This workflow performs basic checks:
#
# 1. run a preparation step to install and cache node modules
# 2. once prep succeeds, run lint and test in parallel
#
# The checks are skipped on the 'main' branch. The project relies on branch
# protection to avoid pushes straight to 'main'.

name: Checks

on:
push:
branches-ignore:
- 'main'

env:
NODE: 16

jobs:
prep:
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest

steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

# Both delta-ui and delta-config are private repos. Since the token issued
# to GH does not have access to the delta-ui submodule, we have to
# manually check it out using a ssh deploy key.
- name: Checkout
uses: actions/checkout@v3
- name: Get submodules
env:
SSH_KEY_SUBMODULE: ${{secrets.DELTA_UI_FETCH_KEY}}
run: |
eval `ssh-agent -s`
ssh-add - <<< "${SSH_KEY_SUBMODULE}"; git submodule update --init --recursive
- name: Use Node.js ${{ env.NODE }}
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE }}

- name: Cache node_modules
uses: actions/cache@v2
id: cache-node-modules
with:
path: |
node_modules
.delta/ui/node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}

- name: Install
run: ./.delta/setup

test:
needs: prep
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

# See comment on checks-yml - prep step
- name: Checkout
uses: actions/checkout@v3
- name: Get submodules
env:
SSH_KEY_SUBMODULE: ${{secrets.DELTA_UI_FETCH_KEY}}
run: |
eval `ssh-agent -s`
ssh-add - <<< "${SSH_KEY_SUBMODULE}"; git submodule update --init --recursive
- name: Use Node.js ${{ env.NODE }}
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE }}

- name: Cache node_modules
uses: actions/cache@v2
id: cache-node-modules
with:
path: |
node_modules
.delta/ui/node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}

- name: Install
run: ./.delta/setup

- name: Test
run: yarn test
119 changes: 119 additions & 0 deletions .github/workflows/deploy-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Deploy the site to AWS S3 on a push to specific branches

name: Deploy Production - MCP (S3)

on:
push:
branches:
- 'main'

env:
NODE: 16
DOMAIN_PROD: https://earthdata.nasa.gov/dashboard
DEPLOY_BUCKET_PROD: climatedashboard
DEPLOY_BUCKET_PROD_REGION: us-east-1

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

# See comment on checks.yml - prep step
- name: Checkout
uses: actions/checkout@v3
- name: Get submodules
env:
SSH_KEY_SUBMODULE: ${{secrets.DELTA_UI_FETCH_KEY}}
run: |
eval `ssh-agent -s`
ssh-add - <<< "${SSH_KEY_SUBMODULE}"; git submodule update --init --recursive
- name: Use Node.js ${{ env.NODE }}
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE }}

- name: Cache node_modules
uses: actions/cache@v2
id: cache-node-modules
with:
path: |
node_modules
.delta/ui/node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}

- name: Cache dist
uses: actions/cache@v2
id: cache-dist
with:
path: dist
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.workflow }}-${{ github.sha }}

- name: Install
run: ./.delta/setup

- name: Build production
run: PUBLIC_URL="${{ env.DOMAIN_PROD }}" yarn build

deploy:
runs-on: ubuntu-latest
needs: build

steps:
# See comment on checks.yml - prep step
- name: Checkout
uses: actions/checkout@v3
- name: Get submodules
env:
SSH_KEY_SUBMODULE: ${{secrets.DELTA_UI_FETCH_KEY}}
run: |
eval `ssh-agent -s`
ssh-add - <<< "${SSH_KEY_SUBMODULE}"; git submodule update --init --recursive
- name: Restore node_modules
uses: actions/cache@v2
id: cache-node-modules
with:
path: |
node_modules
.delta/ui/node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}

- name: Restore dist cache
uses: actions/cache@v2
id: cache-dist
with:
path: dist
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.workflow }}-${{ github.sha }}

- name: Use Node.js ${{ env.NODE }}
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE }}

- name: Serve site from subpath
run: |
mkdir deploy/
mv dist deploy/dashboard
cp deploy/dashboard/index.html deploy/index.html
- name: Deploy to S3 Production
uses: jakejarvis/s3-sync-action@master
with:
# acl is not permitted with current credentials
# args: --acl public-read --follow-symlinks --delete
args: --follow-symlinks --delete
env:
AWS_S3_BUCKET: ${{ env.DEPLOY_BUCKET_PROD }}
AWS_REGION: ${{ env.DEPLOY_BUCKET_PROD_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# When serving from a subpath:
# SOURCE_DIR: ./deploy
# Otherwise use the build directory directly:
# SOURCE_DIR: ./dist
SOURCE_DIR: ./deploy
119 changes: 119 additions & 0 deletions .github/workflows/deploy-staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Deploy the site to AWS S3 on a push to specific branches

name: Deploy Staging - MCP (S3)

on:
push:
branches:
- 'develop'

env:
NODE: 16
DOMAIN_STAGING: https://uat.earthdata.nasa.gov/dashboard
DEPLOY_BUCKET_STAGING: climatedashboard-uat
DEPLOY_BUCKET_STAGING_REGION: us-east-1

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}

# See comment on checks.yml - prep step
- name: Checkout
uses: actions/checkout@v3
- name: Get submodules
env:
SSH_KEY_SUBMODULE: ${{secrets.DELTA_UI_FETCH_KEY}}
run: |
eval `ssh-agent -s`
ssh-add - <<< "${SSH_KEY_SUBMODULE}"; git submodule update --init --recursive
- name: Use Node.js ${{ env.NODE }}
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE }}

- name: Cache node_modules
uses: actions/cache@v2
id: cache-node-modules
with:
path: |
node_modules
.delta/ui/node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}

- name: Cache dist
uses: actions/cache@v2
id: cache-dist
with:
path: dist
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.workflow }}-${{ github.sha }}

- name: Install
run: ./.delta/setup

- name: Build Staging
run: PUBLIC_URL="${{ env.DOMAIN_STAGING }}" yarn stage

deploy:
runs-on: ubuntu-latest
needs: build

steps:
# See comment on checks.yml - prep step
- name: Checkout
uses: actions/checkout@v3
- name: Get submodules
env:
SSH_KEY_SUBMODULE: ${{secrets.DELTA_UI_FETCH_KEY}}
run: |
eval `ssh-agent -s`
ssh-add - <<< "${SSH_KEY_SUBMODULE}"; git submodule update --init --recursive
- name: Restore node_modules
uses: actions/cache@v2
id: cache-node-modules
with:
path: |
node_modules
.delta/ui/node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}

- name: Restore dist cache
uses: actions/cache@v2
id: cache-dist
with:
path: dist
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ github.workflow }}-${{ github.sha }}

- name: Use Node.js ${{ env.NODE }}
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE }}

- name: Serve site from subpath
run: |
mkdir deploy/
mv dist deploy/dashboard
cp deploy/dashboard/index.html deploy/index.html
- name: Deploy to S3 Staging
uses: jakejarvis/s3-sync-action@master
with:
# acl is not permitted with current credentials
# args: --acl public-read --follow-symlinks --delete
args: --follow-symlinks --delete
env:
AWS_S3_BUCKET: ${{ env.DEPLOY_BUCKET_STAGING }}
AWS_REGION: ${{ env.DEPLOY_BUCKET_STAGING_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
# When serving from a subpath:
# SOURCE_DIR: ./deploy
# Otherwise use the build directory directly:
# SOURCE_DIR: ./dist
SOURCE_DIR: ./deploy
Loading

0 comments on commit ca99c42

Please sign in to comment.