Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ inputs:
description: 'Path to file or tar archive (required if source-type=tar/file)'
required: false

x86-64-path:
description: 'Path to tar archive for x86_64 architecture (optional, used with source-type=tar)'
required: false

arm64-path:
description: 'Path to tar archive for arm64 architecture (optional, used with source-type=tar)'
required: false

# Common inputs
setup-commands:
description: 'Newline-separated setup commands to run after agent installation'
Expand Down Expand Up @@ -83,6 +91,12 @@ outputs:
object-id:
description: 'The ID of the uploaded object (if applicable, e.g., obj_xxxx)'

x86-64-object-id:
description: 'The ID of the uploaded x86_64 object (if applicable)'

arm64-object-id:
description: 'The ID of the uploaded arm64 object (if applicable)'

agent-name:
description: 'The final name of the created agent'

Expand Down
119 changes: 93 additions & 26 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

94 changes: 74 additions & 20 deletions src/agent-deployer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,44 @@ async function deployTarAgent(
): Promise<DeploymentResult> {
core.info('Deploying tar agent...');

if (!inputs.path) {
throw new Error('path is required for tar agent deployment');
const objectSource: Record<string, unknown> = {
agent_setup: inputs.setupCommands || [],
};

let firstObjectId: string | undefined;

// Upload universal object if path provided
if (inputs.path) {
const tarPath = resolvePath(inputs.path);
const result = await uploadTarFile(client, tarPath, inputs.objectTtlDays);
objectSource.object_id = result.objectId;
firstObjectId = result.objectId;
core.info(`Universal object uploaded: ${result.objectId}`);
}

const tarPath = resolvePath(inputs.path);
// Upload x86_64 object if path provided
if (inputs.x86_64Path) {
const tarPath = resolvePath(inputs.x86_64Path);
const result = await uploadTarFile(client, tarPath, inputs.objectTtlDays);
objectSource.x86_64_object_id = result.objectId;
firstObjectId = firstObjectId || result.objectId;
core.info(`x86_64 object uploaded: ${result.objectId}`);
}

// Upload tar file
const uploadResult = await uploadTarFile(client, tarPath, inputs.objectTtlDays);
// Upload arm64 object if path provided
if (inputs.arm64Path) {
const tarPath = resolvePath(inputs.arm64Path);
const result = await uploadTarFile(client, tarPath, inputs.objectTtlDays);
objectSource.arm64_object_id = result.objectId;
firstObjectId = firstObjectId || result.objectId;
core.info(`arm64 object uploaded: ${result.objectId}`);
}

if (!firstObjectId) {
throw new Error(
'At least one of path, x86-64-path, or arm64-path is required for tar deployment'
);
}

// Create agent with object source
// Using client.api.post because SDK v1.0.0 types are missing 'version' field in AgentCreateParams
Expand All @@ -137,18 +167,15 @@ async function deployTarAgent(
is_public: inputs.isPublic,
source: {
type: 'object',
object: {
object_id: uploadResult.objectId,
agent_setup: inputs.setupCommands || [],
},
object: objectSource,
},
},
});

return {
agentId: agent.id,
agentName: agent.name,
objectId: uploadResult.objectId,
objectId: firstObjectId,
};
}

Expand All @@ -162,14 +189,44 @@ async function deployFileAgent(
): Promise<DeploymentResult> {
core.info('Deploying file agent...');

if (!inputs.path) {
throw new Error('path is required for file agent deployment');
const objectSource: Record<string, unknown> = {
agent_setup: inputs.setupCommands || [],
};

let firstObjectId: string | undefined;

// Upload universal object if path provided
if (inputs.path) {
const filePath = resolvePath(inputs.path);
const result = await uploadSingleFile(client, filePath, inputs.objectTtlDays, 'binary');
objectSource.object_id = result.objectId;
firstObjectId = result.objectId;
core.info(`Universal object uploaded: ${result.objectId}`);
}

const filePath = resolvePath(inputs.path);
// Upload x86_64 object if path provided
if (inputs.x86_64Path) {
const filePath = resolvePath(inputs.x86_64Path);
const result = await uploadSingleFile(client, filePath, inputs.objectTtlDays, 'binary');
objectSource.x86_64_object_id = result.objectId;
firstObjectId = firstObjectId || result.objectId;
core.info(`x86_64 object uploaded: ${result.objectId}`);
}

// Upload single file
const uploadResult = await uploadSingleFile(client, filePath, inputs.objectTtlDays);
// Upload arm64 object if path provided
if (inputs.arm64Path) {
const filePath = resolvePath(inputs.arm64Path);
const result = await uploadSingleFile(client, filePath, inputs.objectTtlDays, 'binary');
objectSource.arm64_object_id = result.objectId;
firstObjectId = firstObjectId || result.objectId;
core.info(`arm64 object uploaded: ${result.objectId}`);
}

if (!firstObjectId) {
throw new Error(
'At least one of path, x86-64-path, or arm64-path is required for file deployment'
);
}

// Create agent with object source
// Using client.api.post because SDK v1.0.0 types are missing 'version' field in AgentCreateParams
Expand All @@ -180,18 +237,15 @@ async function deployFileAgent(
is_public: inputs.isPublic,
source: {
type: 'object',
object: {
object_id: uploadResult.objectId,
agent_setup: inputs.setupCommands || [],
},
object: objectSource,
},
},
});

return {
agentId: agent.id,
agentName: agent.name,
objectId: uploadResult.objectId,
objectId: firstObjectId,
};
}

Expand Down
6 changes: 3 additions & 3 deletions src/object-uploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ export async function uploadTarFile(
export async function uploadSingleFile(
client: RunloopSDK,
filePath: string,
ttlDays?: number
ttlDays?: number,
contentTypeOverride?: 'text' | 'binary' | 'gzip' | 'tar' | 'tgz'
): Promise<UploadResult> {
core.info(`Uploading single file: ${filePath}`);

const fileBuffer = fs.readFileSync(filePath);
const fileName = path.basename(filePath);

// Determine content type based on file
const contentType = determineContentType(fileName, fileBuffer);
const contentType = contentTypeOverride ?? determineContentType(fileName, fileBuffer);

return uploadBuffer(client, fileBuffer, fileName, contentType, ttlDays);
}
Expand Down
Loading
Loading