Skip to content

Commit 54ab96f

Browse files
authored
Merge pull request #1 from unstubbable/preview
Create preview environment
2 parents 619cd4b + f573e07 commit 54ab96f

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Preview Deployment
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
7+
concurrency:
8+
group: preview-deployment
9+
cancel-in-progress: false
10+
11+
jobs:
12+
deploy-preview:
13+
if: github.event.pull_request.head.repo.full_name == github.repository
14+
runs-on: ubuntu-latest
15+
environment: AWS Preview
16+
env:
17+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
18+
AWS_HANDLER_VERIFY_HEADER: ${{ secrets.AWS_HANDLER_VERIFY_HEADER }}
19+
AWS_REGION: ${{ vars.AWS_REGION }}
20+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
21+
GOOGLE_SEARCH_API_KEY: ${{ secrets.GOOGLE_SEARCH_API_KEY }}
22+
GOOGLE_SEARCH_SEARCH_ENGINE_ID:
23+
${{ secrets.GOOGLE_SEARCH_SEARCH_ENGINE_ID }}
24+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
25+
UPSTASH_REDIS_REST_TOKEN: ${{ secrets.UPSTASH_REDIS_REST_TOKEN }}
26+
UPSTASH_REDIS_REST_URL: ${{ secrets.UPSTASH_REDIS_REST_URL }}
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
- name: Setup Node.js
31+
uses: actions/setup-node@v4
32+
with:
33+
node-version-file: '.node-version'
34+
cache: 'npm'
35+
- name: Install
36+
run: npm ci --no-audit --no-fund
37+
- name: Build
38+
run: npm run build
39+
- name: Deploy Preview
40+
run: npm run deploy:preview -- --require-approval never

cdk/app-preview.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import * as cdk from 'aws-cdk-lib';
2+
import './env.js';
3+
import {Stack} from './stack.js';
4+
5+
const app = new cdk.App();
6+
7+
new Stack(app, `mfng-ai-demo-preview`, {
8+
env: {
9+
account: process.env.CDK_DEFAULT_ACCOUNT,
10+
// A web ACL with CLOUDFRONT scope, and the certificate for CloudFront, must
11+
// both be created in the US East (N. Virginia) Region, us-east-1.
12+
region: `us-east-1`,
13+
},
14+
bucketName: `mfng-ai-demo-preview-assets`,
15+
customDomain: {
16+
domainName: `strict.software`,
17+
subdomainName: `ai-demo-preview.mfng`,
18+
},
19+
webAclName: `mfng-ai-demo-preview`,
20+
});

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"compile:watch": "tsc --build --watch --preserveWatchOutput",
1616
"predeploy": "cdk bootstrap --app 'tsx cdk/app.ts'",
1717
"deploy": "cdk diff --app 'tsx cdk/app.ts' && cdk deploy --app 'tsx cdk/app.ts' --all",
18+
"deploy:preview": "cdk diff --app 'tsx cdk/app-preview.ts' && cdk deploy --app 'tsx cdk/app-preview.ts' --all",
1819
"dev": "turbo watch:dev start",
1920
"format:check": "prettier --check .",
2021
"format:write": "prettier --write .",

0 commit comments

Comments
 (0)