Skip to content

Commit

Permalink
Merge pull request #10 from icssc/fix-workflow
Browse files Browse the repository at this point in the history
added some custom url changes for workflows
  • Loading branch information
stevem-zhou authored May 18, 2024
2 parents a7f97d6 + db4a4ac commit c19d806
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
6 changes: 5 additions & 1 deletion sst.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ export default {
region: "us-east-1",
};
},
stacks(app) {
stacks(app: App) {
if (app.stage !== 'prod') {
app.setDefaultRemovalPolicy('destroy');
}

app
.stack(BackendStack, { stackName: `${app.name}-${app.stage}-backend` })
.stack(FrontendStack, { stackName: `${app.name}-${app.stage}-frontend` });
Expand Down
24 changes: 21 additions & 3 deletions stacks/frontend.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
import { StackContext, StaticSite } from "sst/constructs";

export function FrontendStack({ stack }: StackContext) {
export function FrontendStack({ app, stack }: StackContext) {
const apiUrl = process.env.API_URL as string; // Ensure API_URL is treated as a string

let domainName: string;
let domainAlias: string | undefined;
if (app.stage === "prod") {
domainName = "zotnfound.com";
domainAlias = "www.zotnfound.com";
} else if (app.stage === "dev") {
domainName = "dev.zotnfound.com";
} else if (app.stage.match(/^staging-(\d+)$/)) {
// check if stage is like staging-###
domainName = `${app.stage}.zotnfound.com`;
} else {
throw new Error("Invalid stage");
}

const web = new StaticSite(stack, "web", {
path: "packages/web",
buildOutput: "dist",
buildCommand: "pnpm run build",
customDomain: "zotnfound.com",
customDomain: {
domainName: domainName,
domainAlias: domainAlias,
hostedZone: "zotnfound.com",
},
environment: {
VITE_REACT_APP_AWS_BACKEND_URL: apiUrl, //https://805cgohzr0.execute-api.us-east-1.amazonaws.com/
VITE_REACT_APP_API_KEY: process.env.VITE_REACT_APP_API_KEY!,
Expand All @@ -20,7 +38,7 @@ export function FrontendStack({ stack }: StackContext) {
VITE_REACT_APP_MEASUREMENT_ID: process.env.VITE_REACT_APP_MEASUREMENT_ID!,
},
});

stack.addOutputs({
WebEndpoint: web.customDomainUrl,
});
Expand Down

0 comments on commit c19d806

Please sign in to comment.