Skip to content

Commit

Permalink
chore(embed): deploy code embed renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
tericcabrel committed Sep 3, 2022
1 parent 906e5f8 commit 75fcce0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
19 changes: 7 additions & 12 deletions .github/workflows/deploy-code-embed.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
name: Sharingan Deploy Code Embed
on:
workflow_dispatch:
inputs:
stage:
default: Production
options:
- Production
- Development
description: "Environment to deploy on"
required: true
pull_request:
branches:
- main
push:
branches:
- main
- dev
paths:
- 'packages/database/prisma/**'
- 'packages/database/src/**'
Expand All @@ -21,7 +16,7 @@ on:
jobs:
deploy:
runs-on: ubuntu-latest
environment: ${{ github.event.inputs.stage }}
environment: ${{ (github.ref == 'refs/heads/main' && 'Production') || 'Development' }}
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
EMBED_STYLE_URL: ${{ secrets.EMBED_STYLE_URL }}
Expand All @@ -41,14 +36,14 @@ jobs:

- name: Deploy the application in staging
working-directory: 'apps/functions/code-embed'
if: ${{ github.event.inputs.stage == 'Development' }}
if: ${{ github.ref == 'refs/heads/dev' }}
run: |
yarn setup:layer:remote
yarn sls deploy --stage dev
- name: Deploy the application in production
working-directory: 'apps/functions/code-embed'
if: ${{ github.event.inputs.stage == 'Production' }}
if: ${{ github.ref != 'refs/heads/main' }}
run: |
yarn setup:layer:remote
yarn sls deploy --stage prod
Expand Down
11 changes: 9 additions & 2 deletions apps/functions/code-embed/scripts/setup-layer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,16 @@ yarn workspace @sharingan/database db:generate

cp -r node_modules/.prisma apps/functions/code-embed/layers/prisma-layer/nodejs/node_modules

PRISMA_ENGINE_MACOS=apps/functions/code-embed/layers/prisma-layer/nodejs/node_modules/.prisma/client/libquery_engine-darwin.dylib.node
PRISMA_ENGINE_DOCKER_LINUX=apps/functions/code-embed/layers/prisma-layer/nodejs/node_modules/.prisma/client/libquery_engine-linux-musl.so.node

if [ $1 = "remote" ]; then
rm apps/functions/code-embed/layers/prisma-layer/nodejs/node_modules/.prisma/client/libquery_engine-darwin.dylib.node
rm apps/functions/code-embed/layers/prisma-layer/nodejs/node_modules/.prisma/client/libquery_engine-linux-musl.so.node
if [ -f "$PRISMA_ENGINE_MACOS" ]; then
rm $PRISMA_ENGINE_MACOS
fi
if [ -f "$PRISMA_ENGINE_DOCKER_LINUX" ]; then
rm $PRISMA_ENGINE_DOCKER_LINUX
fi
else
echo 'local'
fi
Expand Down

0 comments on commit 75fcce0

Please sign in to comment.