Skip to content

Deploy pinned projects fix #186

Deploy pinned projects fix

Deploy pinned projects fix #186

Workflow file for this run

name: Deep client Deployment
on:
push:
branches:
- main
jobs:
deploy_config:
name: Read deploy config
runs-on: ubuntu-latest
outputs:
deploy: ${{ steps.config.outputs.deploy }}
branch: ${{ steps.config.outputs.branch }}
repo: ${{ steps.config.outputs.repo }}
deep_version: ${{ steps.config.outputs.deep_version }}
deep_deploy_datetime: ${{ steps.config.outputs.deep_deploy_datetime }}
steps:
- uses: actions/checkout@v2
- name: Read deploy config
id: config
run: |
SUB_MODULES_DEP_FILE=./deploy.json
DEEP_CLIENT_DEPLOY=`jq -r '.client.deploy' ${SUB_MODULES_DEP_FILE}`
DEEP_CLIENT_REPO=`jq -r '.client.repo' ${SUB_MODULES_DEP_FILE}`
DEEP_CLIENT_BRANCH=`jq -r '.client.branch' ${SUB_MODULES_DEP_FILE}`
DEEP_VERSION=`jq -r '.deep_version' ${SUB_MODULES_DEP_FILE}`
DEEP_DEPLOY_DATETIME=`date +'%FT%T%z'`
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 "deep_version=${DEEP_VERSION}" >> $GITHUB_OUTPUT
echo "deep_deploy_datetime=${DEEP_DEPLOY_DATETIME}" >> $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: 🐳 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 }}-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 }}
REACT_APP_RELEASE_VERSION: ${{ needs.deploy_config.outputs.deep_version }}
REACT_APP_RELEASE_TIME: ${{ needs.deploy_config.outputs.deep_deploy_datetime }}
# 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_STATIC_ENDPOINT: https://deep-staging-web-addonsstack-qz1nywpr9fyp-media.s3.amazonaws.com
REACT_APP_SERVERLESS_DOMAIN: https://services-alpha.thedeep.io
REACT_APP_PDF_CACHE_ENDPOINT: https://snapshot-proxy.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_OLD_BROWSER_EXTENSION_ID: kafonkgglonkbldmcigbdojiadfcmcdc
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: client-build-staging
path: ./client/build/
- name: Build [Prod]
env:
DOCKER_IMAGE: ${{ steps.prep.outputs.tagged_image }}
REACT_APP_RELEASE_VERSION: ${{ needs.deploy_config.outputs.deep_version }}
REACT_APP_RELEASE_TIME: ${{ needs.deploy_config.outputs.deep_deploy_datetime }}
# 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_STATIC_ENDPOINT: https://deep-prod-web-addonsstack-1wxq3ye6f4n4b-media.s3.amazonaws.com
REACT_APP_SERVERLESS_DOMAIN: https://services.thedeep.io
REACT_APP_PDF_CACHE_ENDPOINT: https://snapshot-proxy.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: client-build-prod
path: ./client/build/
staging_deploy:
name: Deploy (STAGING)
runs-on: ubuntu-latest
environment:
name: staging
url: https://staging.thedeep.io
needs: test_build
steps:
- uses: actions/download-artifact@v1
with:
name: 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-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://app.thedeep.io
needs: [test_build, staging_deploy]
steps:
- uses: actions/download-artifact@v1
with:
name: 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-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'