Create multiple workflows for different actions
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
import * as core from '@actions/core';
|
||||
import * as fs from 'fs/promises';
|
||||
import * as path from 'path';
|
||||
import { existsSync } from 'fs';
|
||||
|
||||
async function copyDirectory(src: string, dest: string): Promise<void> {
|
||||
await fs.mkdir(dest, { recursive: true });
|
||||
const entries = await fs.readdir(src, { withFileTypes: true });
|
||||
|
||||
for (const entry of entries) {
|
||||
const srcPath = path.join(src, entry.name);
|
||||
const destPath = path.join(dest, entry.name);
|
||||
|
||||
if (entry.isDirectory()) {
|
||||
await copyDirectory(srcPath, destPath);
|
||||
} else {
|
||||
await fs.copyFile(srcPath, destPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function run() {
|
||||
try {
|
||||
const destinationPath = core.getInput('destination-path');
|
||||
if (!destinationPath) {
|
||||
core.setFailed('Destination path is required.');
|
||||
return;
|
||||
}
|
||||
|
||||
// Reference lua-addons relative to the dist directory
|
||||
// __dirname is dist/, so lua-addons is one level up
|
||||
const bundledAddonsDir = path.resolve(__dirname, '../lua-addons');
|
||||
|
||||
// Verify bundled addons directory exists
|
||||
if (!existsSync(bundledAddonsDir)) {
|
||||
core.setFailed(`Lua-addons directory not found at: ${bundledAddonsDir}`);
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the workspace root and resolve destination path
|
||||
const workspaceRoot = process.env.GITHUB_WORKSPACE || process.cwd();
|
||||
const absoluteDestinationPath = path.join(workspaceRoot, destinationPath);
|
||||
|
||||
core.info(`Copying lua-addons to: ${absoluteDestinationPath}`);
|
||||
|
||||
// Create destination directory if it doesn't exist
|
||||
await fs.mkdir(absoluteDestinationPath, { recursive: true });
|
||||
|
||||
// Copy all bundled addons to the destination
|
||||
const addons = await fs.readdir(bundledAddonsDir, { withFileTypes: true });
|
||||
for (const addon of addons) {
|
||||
if (addon.isDirectory()) {
|
||||
const sourceAddonDir = path.join(bundledAddonsDir, addon.name);
|
||||
const destAddonDir = path.join(absoluteDestinationPath, addon.name);
|
||||
|
||||
core.info(`Installing addon: ${addon.name}`);
|
||||
await copyDirectory(sourceAddonDir, destAddonDir);
|
||||
core.info(`✓ ${addon.name} installed`);
|
||||
}
|
||||
}
|
||||
|
||||
core.info('Lua addons installation completed successfully.');
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
core.setFailed(error.message);
|
||||
} else {
|
||||
core.setFailed('An unknown error occurred');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
run();
|
||||
Reference in New Issue
Block a user