Automate via workflows. Add auto-archiving for downgrade. (#581)

This commit is contained in:
Nerivec
2024-10-28 21:38:11 +01:00
committed by GitHub
parent c1c4488759
commit ea2e6693f8
60 changed files with 10052 additions and 323 deletions
+41
View File
@@ -0,0 +1,41 @@
import type CoreApi from '@actions/core';
import type {Context} from '@actions/github/lib/context';
import type {Octokit} from '@octokit/rest';
import {existsSync, mkdirSync} from 'fs';
import {ALL_AUTODL_MANUFACTURERS, CACHE_DIR} from './common.js';
export async function overwriteCache(github: Octokit, core: typeof CoreApi, context: Context, manufacturersCSV?: string): Promise<void> {
if (!existsSync(CACHE_DIR)) {
mkdirSync(CACHE_DIR, {recursive: true});
}
const manufacturers = manufacturersCSV ? manufacturersCSV.trim().split(',') : ALL_AUTODL_MANUFACTURERS;
for (const manufacturer of manufacturers) {
// ignore empty strings
if (!manufacturer) {
continue;
}
if (!ALL_AUTODL_MANUFACTURERS.includes(manufacturer)) {
core.error(`Ignoring invalid manufacturer '${manufacturer}'. Expected any of: ${ALL_AUTODL_MANUFACTURERS}.`);
continue;
}
const {writeCache} = await import(`./${manufacturer}.js`);
core.startGroup(manufacturer);
core.info(`[${manufacturer}] Writing cache...`);
try {
await writeCache();
} catch (error) {
core.error((error as Error).message);
core.debug((error as Error).stack!);
}
core.endGroup();
}
}