Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create preview environment #1

Merged
merged 1 commit into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/preview-deployment.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