chore: 增加部署状态与备份保留
This commit is contained in:
1 parent
d2ca528543
commit
7f67f4d685
5 files changed
+75
No files matched your search
@@ -157,6 +157,15 @@ async function backupDatabase(destination) {
|
||||
await rename(temporary, destination);
|
||||
}
|
||||
|
||||
async function pruneBackups(directory) {
|
||||
const backups = (await readdir(directory, { withFileTypes: true }))
|
||||
.filter((entry) => entry.isFile() && entry.name.endsWith(".dump"))
|
||||
.map((entry) => entry.name)
|
||||
.sort()
|
||||
.reverse();
|
||||
for (const backup of backups.slice(7)) await rm(path.join(directory, backup));
|
||||
}
|
||||
|
||||
async function copyMissingFiles(sourceDirectory, destinationDirectory) {
|
||||
await mkdir(destinationDirectory, { recursive: true });
|
||||
for (const entry of await readdir(sourceDirectory, { withFileTypes: true })) {
|
||||
@@ -318,6 +327,7 @@ try {
|
||||
);
|
||||
run("pnpm", ["--filter", "@personal-brand/api", "exec", "prisma", "generate"], release);
|
||||
await backupDatabase(path.join(root, "shared/backups", manifest.version + ".dump"));
|
||||
await pruneBackups(path.join(root, "shared/backups"));
|
||||
run("pnpm", ["--filter", "@personal-brand/api", "exec", "prisma", "migrate", "deploy"], release);
|
||||
const seedDirectory = path.join(process.env.LOCAL_MEDIA_ROOT, "seed");
|
||||
await copyMissingFiles(path.join(release, "seed-media"), seedDirectory);
|
||||
|
||||
Reference in new issue
Block a user