Skip to content

Commit

Permalink
Create preview environment
Browse files Browse the repository at this point in the history
  • Loading branch information
unstubbable committed Mar 17, 2024
1 parent 619cd4b commit cfe5035
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/deployment-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Preview Deployment

on:
pull_request:
types: [opened, synchronize, reopened]

concurrency:
group: preview-deployment
cancel-in-progress: false

jobs:
deploy-preview:
if: github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
environment: AWS Preview
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_HANDLER_VERIFY_HEADER: ${{ secrets.AWS_HANDLER_VERIFY_HEADER }}
AWS_REGION: ${{ vars.AWS_REGION }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
GOOGLE_SEARCH_API_KEY: ${{ secrets.GOOGLE_SEARCH_API_KEY }}
GOOGLE_SEARCH_SEARCH_ENGINE_ID:
${{ secrets.GOOGLE_SEARCH_SEARCH_ENGINE_ID }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
UPSTASH_REDIS_REST_TOKEN: ${{ secrets.UPSTASH_REDIS_REST_TOKEN }}
UPSTASH_REDIS_REST_URL: ${{ secrets.UPSTASH_REDIS_REST_URL }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: '.node-version'
cache: 'npm'
- name: Install
run: npm ci --no-audit --no-fund
- name: Build
run: npm run build
- name: Deploy Preview
run: npm run deploy:preview -- --require-approval never
20 changes: 20 additions & 0 deletions cdk/app-preview.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import * as cdk from 'aws-cdk-lib';
import './env.js';
import {Stack} from './stack.js';

const app = new cdk.App();

new Stack(app, `mfng-ai-demo-preview`, {
env: {
account: process.env.CDK_DEFAULT_ACCOUNT,
// A web ACL with CLOUDFRONT scope, and the certificate for CloudFront, must
// both be created in the US East (N. Virginia) Region, us-east-1.
region: `us-east-1`,
},
bucketName: `mfng-ai-demo-preview-assets`,
customDomain: {
domainName: `strict.software`,
subdomainName: `ai-demo-preview.mfng`,
},
webAclName: `mfng-ai-demo-preview`,
});
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"compile:watch": "tsc --build --watch --preserveWatchOutput",
"predeploy": "cdk bootstrap --app 'tsx cdk/app.ts'",
"deploy": "cdk diff --app 'tsx cdk/app.ts' && cdk deploy --app 'tsx cdk/app.ts' --all",
"deploy:preview": "cdk diff --app 'tsx cdk/app-preview.ts' && cdk deploy --app 'tsx cdk/app-preview.ts' --all",
"dev": "turbo watch:dev start",
"format:check": "prettier --check .",
"format:write": "prettier --write .",
Expand Down

0 comments on commit cfe5035

Please sign in to comment.