Skip to content

Commit

Permalink
Merge pull request #210 from Hen-Dricks/migration-to-2024
Browse files Browse the repository at this point in the history
  • Loading branch information
JonnyBurger authored Dec 18, 2024
2 parents 32d1bca + 66a875c commit 9ac98da
Show file tree
Hide file tree
Showing 80 changed files with 4,884 additions and 2,976 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
{
"files": ["src/**/*.{ts,tsx}"],
"extends": ["@jonny", "plugin:require-extensions/recommended"]
"extends": ["@jonny"]
}
]
}
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"typescript.enablePromptUseWorkspaceTsdk": true,
"typescript.tsdk": "node_modules/typescript/lib"
}
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ A platform that generates a year-in-review video for each GitHub user. Built wit

Want to make your own year-in-review for your users?

- **Developers**: Feel free to fork and use this repository as a template! Note the legal disclaimers at the bottom of this README.
- **Non-developers**: Write to [hi@remotion.dev](mailto:hi@remotion.dev) for a free consultation in Fall 2024!
Feel free to fork and use this repository as a template! Note the legal disclaimers at the bottom of this README.

## Versions

- 2024: `main` branch
- 2023: `2023` branch
- 2022: [`github-unwrapped-2022` Repo](https://github.com/remotion-dev/github-unwrapped-2022)
- 2021: [`github-unwrapped-2021` Repo](https://github.com/remotion-dev/github-unwrapped-2021)

## Setup

Expand Down
78 changes: 78 additions & 0 deletions delete.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import type { AwsRegion } from "@remotion/lambda";
import { getAwsClient, getOrCreateBucket, getRegions } from "@remotion/lambda";
import dotenv from "dotenv";
import pLimit from "p-limit";
import { getAccountCount } from "./src/helpers/get-account-count";
import { setEnvForKey } from "./src/helpers/set-env-for-key";

dotenv.config();

const count = getAccountCount();
console.log(`Found ${count} accounts. Deploying...`);

const limit = pLimit(10);

const doTheThingForRegion = (i: number, region: AwsRegion) =>
limit(async () => {
setEnvForKey(i);
const { bucketName } = await getOrCreateBucket({ region });
const { sdk, client } = getAwsClient({ region, service: "s3" });
const results = [];

let contToken: string | undefined;
// eslint-disable-next-line no-constant-condition
while (true) {
const res = await client.send(
new sdk.ListObjectsV2Command({
Bucket: bucketName,
Prefix: "renders",
ContinuationToken: contToken,
}),
);
if ((res.Contents?.length ?? 0) > 0) {
await client.send(
new sdk.DeleteObjectsCommand({
Bucket: bucketName,
Delete: {
Objects: res.Contents?.map((c) => ({
Key: c.Key as string,
})),
},
}),
);

results.push(...(res.Contents ?? []));
console.log(
"Deleted",
results.length,
"objects in",
bucketName,
"in",
region,
"for account",
i,
);
} else {
console.log(
"No more objects to delete in",
bucketName,
"in",
region,
"for account",
i,
);
}

if (!res.NextContinuationToken) {
break;
}

contToken = res.NextContinuationToken;
}
});

for (let i = 1; i <= count; i++) {
for (const region of getRegions()) {
doTheThingForRegion(i, region);
}
}
6 changes: 5 additions & 1 deletion deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@ for (let i = 2; i <= count; i++) {
memorySizeInMb: RAM,
timeoutInSeconds: TIMEOUT,
region,
enableV5Runtime: true,
});
console.log(
` ${
alreadyExisted ? "Ensured" : "Deployed"
} function "${functionName}" to ${region} in account ${i}`,
);
const { bucketName } = await getOrCreateBucket({ region });
const { bucketName } = await getOrCreateBucket({
region,
enableFolderExpiry: true,
});
const { serveUrl } = await deploySite({
siteName: SITE_NAME,
bucketName,
Expand Down
Loading

0 comments on commit 9ac98da

Please sign in to comment.