Skip to content

Deploy maps and charts in reporting module #168

Deploy maps and charts in reporting module

Deploy maps and charts in reporting module #168

Workflow file for this run

name: Deep client Deployment (ARY only)
on:
push:
branches:
- main
jobs:
deploy_config:
name: Read deploy config
runs-on: ubuntu-latest
outputs:
deploy: ${{ steps.config.outputs.deploy }}
repo: ${{ steps.config.outputs.repo }}
branch: ${{ steps.config.outputs.branch }}
react_store_branch: ${{ steps.config.outputs.react_store_branch }}
react_store_repo: ${{ steps.config.outputs.react_store_repo }}
steps:
- uses: actions/checkout@v2
- name: Read deploy config
id: config
run: |
SUB_MODULES_DEP_FILE=./deploy.json
DEEP_CLIENT_DEPLOY=`jq -r '.ary_client.deploy' ${SUB_MODULES_DEP_FILE}`
DEEP_CLIENT_REPO=`jq -r '.ary_client.repo' ${SUB_MODULES_DEP_FILE}`
DEEP_CLIENT_BRANCH=`jq -r '.ary_client.branch' ${SUB_MODULES_DEP_FILE}`
DEEP_REACT_STORE_REPO=`jq -r '.ary_client.react_store_repo' ${SUB_MODULES_DEP_FILE}`
DEEP_REACT_STORE_BRANCH=`jq -r '.ary_client.react_store_branch' ${SUB_MODULES_DEP_FILE}`
echo "deploy=${DEEP_CLIENT_DEPLOY}" >> $GITHUB_OUTPUT
echo "branch=${DEEP_CLIENT_BRANCH}" >> $GITHUB_OUTPUT
echo "repo=${DEEP_CLIENT_REPO#https://github.com/}" >> $GITHUB_OUTPUT
echo "react_store_repo=${DEEP_REACT_STORE_REPO#https://github.com/}" >> $GITHUB_OUTPUT
echo "react_store_branch=${DEEP_REACT_STORE_BRANCH}" >> $GITHUB_OUTPUT
test_build:
name: Lint + Test + Build
needs: deploy_config
if: ${{ needs.deploy_config.outputs.deploy == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Clone client
uses: actions/checkout@v2
with:
repository: ${{ needs.deploy_config.outputs.repo }}
ref: ${{ needs.deploy_config.outputs.branch }}
path: ./client
- name: Clone client
uses: actions/checkout@v2
with:
repository: ${{ needs.deploy_config.outputs.react_store_repo }}
ref: ${{ needs.deploy_config.outputs.react_store_branch }}
path: ./client/src/vendor/react-store
- name: 🐳 Prepare Docker
id: prep
run: |
TAG=$(echo $GITHUB_SHA | head -c7)
IMAGE="docker.pkg.github.com/the-deep/client"
echo "tagged_image=${IMAGE}:${TAG}" >> $GITHUB_OUTPUT
echo "tag=${TAG}" >> $GITHUB_OUTPUT
- name: 🐳 Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master
- name: 🐳 Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-single-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-ary-single-buildx
- name: 🐳 Build image
uses: docker/build-push-action@v2
with:
context: ./client/ # Custom
builder: ${{ steps.buildx.outputs.name }}
file: ./client/Dockerfile # Custom
push: false # This would be set to true in a real world deployment scenario.
load: true
tags: ${{ steps.prep.outputs.tagged_image }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache-new
- name: 🤞 Run Build + Lint + Test 🧪
env:
DOCKER_IMAGE: ${{ steps.prep.outputs.tagged_image }}
run: |
python -c "import fcntl; fcntl.fcntl(1, fcntl.F_SETFL, 0)" && \
docker run --rm --workdir="/code/" $DOCKER_IMAGE sh -c 'yarn lint'
# Temp fix
# https://github.com/docker/build-push-action/blob/master/docs/advanced/cache.md#github-cache
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: 🐳 Move docker cache (🧙 Hack fix)
run: |
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
# [End] From client .github/workflows/ci.yml
- name: Build [Staging]
env:
DOCKER_IMAGE: ${{ steps.prep.outputs.tagged_image }}
# Misc
REACT_APP_DEEP_ENVIRONMENT: staging
REACT_APP_DEBUG_MODE: true
# Endpoints
REACT_APP_API_HTTPS: https
REACT_APP_API_END: staging-api.thedeep.io
REACT_APP_GRAPHQL_ENDPOINT: https://staging-api.thedeep.io/graphql
REACT_APP_SERVERLESS_DOMAIN: https://services-alpha.thedeep.io
# Iframes
REACT_APP_ASSESSMENT_REGISTRY_END: https://staging-ary.thedeep.io
REACT_APP_ASSESSMENT_VIZ_URL: https://the-deep.github.io/deepviz-assessments/
REACT_APP_ENTRY_VIZ_URL: https://the-deep.github.io/deepviz-entries/
# Chrome extension
REACT_APP_BROWSER_EXTENSION_ID: hkmakfhfikfhllpkfpkkaoonapclfajf
# Mapbox # FIXME: Make sure to use valid token for deep domain.
REACT_APP_MAPBOX_STYLE: mapbox://styles/deepmapz/cjc8oth8775tu2sr0eeymm3qv
REACT_APP_MAPBOX_ACCESS_TOKEN: pk.eyJ1IjoiZGVlcG1hcHoiLCJhIjoiY2pjMjN1bjBxMGJmYjJ3bnpwZXlydzNkeiJ9.vYTnFCIPiRCT8jA33Dti5A
# Google Analytics
REACT_APP_GA_TRACKING_ID: UA-112330910-1
# Sentry
REACT_APP_SENTRY_DSN: https://[email protected]/1220157
REACT_APP_SENTRY_TRACES_SAMPLE_RATE: 0.2
REACT_APP_SENTRY_NORMALIZE_DEPTH: 5
# HID
REACT_APP_HID_CLIENT_ID: deeper-staging
REACT_APP_HID_CLIENT_REDIRECT_URL: https://staging.thedeep.io/login/
REACT_APP_HID_AUTH_URI: https://auth.humanitarian.id
# Hcaptcha
REACT_APP_HCATPCHA_SITEKEY: ac332154-0c48-4fc1-9092-e52b291d903c
# Google Drive
REACT_APP_GOOGLE_DRIVE_DEVELOPER_KEY: AIzaSyAcaVOYWk0zGL9TVQfKXdziFI-5pEkw6X4
REACT_APP_GOOGLE_DRIVE_CLIENT_KEY: 642927279233-ht6v3t7h37cc4gjh336sbin6hdlup2vi.apps.googleusercontent.com
run: |
env > env && \
docker run --rm --env-file=./env -v `pwd`/client/build:/code/build $DOCKER_IMAGE sh -c 'yarn install && CI=false NODE_OPTIONS=--max_old_space_size=4096 yarn build'
- name: Upload artifacts [Staging]
uses: actions/upload-artifact@v2
with:
name: ary-client-build-staging
path: ./client/build/
- name: Build [Prod]
env:
DOCKER_IMAGE: ${{ steps.prep.outputs.tagged_image }}
# Misc
REACT_APP_DEEP_ENVIRONMENT: prod
REACT_APP_DEBUG_MODE: false
# Endpoints
REACT_APP_API_HTTPS: https
REACT_APP_API_END: prod-api.thedeep.io
REACT_APP_GRAPHQL_ENDPOINT: https://prod-api.thedeep.io/graphql
REACT_APP_SERVERLESS_DOMAIN: https://services.thedeep.io
# Iframes
REACT_APP_ASSESSMENT_REGISTRY_END: https://prod-ary.thedeep.io
REACT_APP_ASSESSMENT_VIZ_URL: https://the-deep.github.io/deepviz-assessments/
REACT_APP_ENTRY_VIZ_URL: https://the-deep.github.io/deepviz-entries/
# Chrome extension
REACT_APP_BROWSER_EXTENSION_ID: hkmakfhfikfhllpkfpkkaoonapclfajf
# Mapbox # FIXME: Make sure to use valid token for deep domain.
REACT_APP_MAPBOX_ACCESS_TOKEN: pk.eyJ1IjoiZGVlcG1hcHoiLCJhIjoiY2pjMjN1bjBxMGJmYjJ3bnpwZXlydzNkeiJ9.vYTnFCIPiRCT8jA33Dti5A
REACT_APP_MAPBOX_STYLE: mapbox://styles/deepmapz/cjc8oth8775tu2sr0eeymm3qv
# Google Analytics
REACT_APP_GA_TRACKING_ID: UA-112330910-1
# Sentry
REACT_APP_SENTRY_DSN: https://[email protected]/1220157
REACT_APP_SENTRY_TRACES_SAMPLE_RATE: 0.2
REACT_APP_SENTRY_NORMALIZE_DEPTH: 5
# HID
REACT_APP_HID_CLIENT_ID: deeper-prod
REACT_APP_HID_CLIENT_REDIRECT_URL: https://app.thedeep.io/login/
REACT_APP_HID_AUTH_URI: https://auth.humanitarian.id
# Hcaptcha
REACT_APP_HCATPCHA_SITEKEY: ac332154-0c48-4fc1-9092-e52b291d903c
# Google Drive
REACT_APP_GOOGLE_DRIVE_DEVELOPER_KEY: AIzaSyAcaVOYWk0zGL9TVQfKXdziFI-5pEkw6X4
REACT_APP_GOOGLE_DRIVE_CLIENT_KEY: 642927279233-ht6v3t7h37cc4gjh336sbin6hdlup2vi.apps.googleusercontent.com
run: |
env > env && \
docker run --rm --env-file=./env -v `pwd`/client/build:/code/build $DOCKER_IMAGE sh -c 'yarn install && CI=false NODE_OPTIONS=--max_old_space_size=4096 yarn build'
- name: Upload artifacts [Prod]
uses: actions/upload-artifact@v2
with:
name: ary-client-build-prod
path: ./client/build/
staging_deploy:
name: Deploy (STAGING)
runs-on: ubuntu-latest
environment:
name: staging
url: https://staging-ary.thedeep.io
needs: test_build
steps:
- uses: actions/download-artifact@v1
with:
name: ary-client-build-staging
path: build
# Copy build to S3
- name: S3 Sync
uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read --follow-symlinks --delete
env:
AWS_S3_BUCKET: deep-staging-ary-client
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
SOURCE_DIR: './build'
# Invalidate Cloudfront (this action)
- name: Cloudfront Invalidate
uses: chetan/invalidate-cloudfront-action@master
env:
DISTRIBUTION: ${{ secrets.AWS_CDN_DISTRIBUTION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
PATHS: '/index.html'
prod_deploy:
name: Deploy (PROD)
runs-on: ubuntu-latest
environment:
name: prod
url: https://prod-ary.thedeep.io
needs: [test_build, staging_deploy]
steps:
- uses: actions/download-artifact@v1
with:
name: ary-client-build-prod
path: build
# Copy build to S3
- name: S3 Sync
uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read --follow-symlinks --delete
env:
AWS_S3_BUCKET: deep-prod-ary-client
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
SOURCE_DIR: './build'
# Invalidate Cloudfront (this action)
- name: Cloudfront Invalidate
uses: chetan/invalidate-cloudfront-action@master
env:
DISTRIBUTION: ${{ secrets.ARY_AWS_CDN_DISTRIBUTION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
PATHS: '/index.html'