mirror of
https://github.com/nestriness/nestri.git
synced 2025-12-12 08:45:38 +02:00
✨ feat: Add www to cloudflare pages (#105)
Co-authored-by: --global <--global> Add our website to cloudflare pages
This commit is contained in:
9
infra/domain.ts
Normal file
9
infra/domain.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export const domain =
|
||||
{
|
||||
production: "fst.so",
|
||||
dev: "dev.fst.so",
|
||||
}[$app.stage] || $app.stage + ".dev.fst.so";
|
||||
|
||||
export const zone = cloudflare.getZoneOutput({
|
||||
name: "fst.so",
|
||||
});
|
||||
38
infra/github.ts
Normal file
38
infra/github.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { isPermanentStage } from "./stage";
|
||||
|
||||
if (isPermanentStage) {
|
||||
const github = new aws.iam.OpenIdConnectProvider("GithubProvider", {
|
||||
url: "https://token.actions.githubusercontent.com",
|
||||
clientIdLists: ["sts.amazonaws.com"],
|
||||
thumbprintLists: [
|
||||
"6938fd4d98bab03faadb97b34396831e3780aea1",
|
||||
"1c58a3a8518e8759bf075b76b750d4f2df264fcd",
|
||||
],
|
||||
});
|
||||
|
||||
const githubRole = new aws.iam.Role("GithubRole", {
|
||||
name: [$app.name, $app.stage, "github"].join("-"),
|
||||
assumeRolePolicy: {
|
||||
Version: "2012-10-17",
|
||||
Statement: [
|
||||
{
|
||||
Effect: "Allow",
|
||||
Principal: {
|
||||
Federated: github.arn,
|
||||
},
|
||||
Action: "sts:AssumeRoleWithWebIdentity",
|
||||
Condition: {
|
||||
StringLike: github.url.apply((url) => ({
|
||||
[`${url}:sub`]: "repo:nestriness/nestri:*",
|
||||
})),
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
new aws.iam.RolePolicyAttachment("GithubRolePolicy", {
|
||||
policyArn: "arn:aws:iam::aws:policy/AdministratorAccess",
|
||||
role: githubRole.name,
|
||||
});
|
||||
}
|
||||
5
infra/secrets.ts
Normal file
5
infra/secrets.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export const secret = {
|
||||
CloudflareAccountIdSecret: new sst.Secret("CloudflareAccountId"),
|
||||
};
|
||||
|
||||
export const allSecrets = Object.values(secret);
|
||||
2
infra/stage.ts
Normal file
2
infra/stage.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export const isPermanentStage =
|
||||
$app.stage === "production" || $app.stage === "dev";
|
||||
36
infra/www.ts
Normal file
36
infra/www.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
//Deploys the website to cloudflare pages under the domain nestri.io (redirects all requests to www.nestri.io to avoid duplicate content)
|
||||
// const cloudflareAccountId = new sst.Secret("CloudflareAccountId");
|
||||
|
||||
export const www = new cloudflare.PagesProject("www", {
|
||||
name: "nestri",
|
||||
accountId: "8405b2acb6746935b975bc2cfcb5c288",
|
||||
productionBranch: "main",
|
||||
buildConfig: {
|
||||
rootDir: "apps/www",
|
||||
// buildCommand: "bun run build",
|
||||
destinationDir: "dist"
|
||||
},
|
||||
deploymentConfigs: {
|
||||
production: {
|
||||
compatibilityFlags: ["nodejs_compat"]
|
||||
},
|
||||
preview: {
|
||||
compatibilityFlags: ["nodejs_compat"]
|
||||
}
|
||||
},
|
||||
source: {
|
||||
type: "github",
|
||||
config: {
|
||||
owner: "nestriness",
|
||||
deploymentsEnabled: true,
|
||||
productionBranch: "main",
|
||||
repoName: "nestri",
|
||||
productionDeploymentEnabled: true,
|
||||
prCommentsEnabled: true,
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
export const outputs = {
|
||||
www: www.subdomain,
|
||||
};
|
||||
Reference in New Issue
Block a user