Imported AI generated TypeScript action skeleton.

This commit is contained in:
2026-01-10 22:04:18 +01:00
commit e7d0039424
7 changed files with 291 additions and 0 deletions

49
src/index.ts Normal file
View File

@@ -0,0 +1,49 @@
import * as core from '@actions/core';
import * as tc from '@actions/tool-cache';
import * as path from 'path';
async function run() {
try {
const toolUrl = core.getInput('tool-url', { required: true });
const toolName = core.getInput('tool-name', { required: true });
const version = core.getInput('version') || 'latest';
core.info(`Downloading ${toolName} from ${toolUrl}...`);
// Download the tool
const downloadPath = await tc.downloadTool(toolUrl);
core.info(`Downloaded to ${downloadPath}`);
// If it's an archive, we might need to extract it.
// For simplicity, let's assume it's just a binary for now,
// or we can add extraction logic if the URL ends in .tar.gz, .zip etc.
let toolDir: string;
if (toolUrl.endsWith('.tar.gz')) {
toolDir = await tc.extractTar(downloadPath);
} else if (toolUrl.endsWith('.zip')) {
toolDir = await tc.extractZip(downloadPath);
} else {
// Treat as a direct binary download
// We might need to make it executable and put it in a directory
toolDir = path.dirname(downloadPath);
// Optional: rename if needed, but downloadTool usually gives a random name
}
core.info(`Tool extracted/located at ${toolDir}`);
// Add to path
core.addPath(toolDir);
core.info(`Added ${toolDir} to PATH`);
// In a real scenario, we'd use tc.cacheDir to cache it for future runs
// cachedPath = await tc.cacheDir(toolDir, toolName, version);
// core.addPath(cachedPath);
} catch (error) {
if (error instanceof Error) {
core.setFailed(error.message);
}
}
}
run();