35 lines
978 B
JavaScript
35 lines
978 B
JavaScript
#!/usr/bin/env node
|
|
// Self-bootstrapping entry point — only uses Node stdlib so it runs before
|
|
// node_modules exists. Installs deps, then dynamically imports the action.
|
|
|
|
import { existsSync } from "node:fs";
|
|
import { execSync } from "node:child_process";
|
|
import { fileURLToPath } from "node:url";
|
|
import { dirname } from "node:path";
|
|
|
|
const dir = dirname(fileURLToPath(import.meta.url));
|
|
|
|
if (!existsSync(`${dir}/node_modules`)) {
|
|
console.error("» installing dependencies...");
|
|
execSync("npm install --no-fund --no-audit", {
|
|
cwd: dir,
|
|
stdio: "inherit",
|
|
timeout: 120_000,
|
|
});
|
|
}
|
|
|
|
const [{ main }, core] = await Promise.all([
|
|
import(`${dir}/main.ts`),
|
|
import("@actions/core"),
|
|
]);
|
|
|
|
main()
|
|
.then((result: { success: boolean; error?: string }) => {
|
|
if (!result.success) {
|
|
core.setFailed(result.error ?? "shockbot run failed");
|
|
}
|
|
})
|
|
.catch((err: unknown) => {
|
|
core.setFailed(err instanceof Error ? err.message : String(err));
|
|
});
|