-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
46 lines (40 loc) · 1.6 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const core = require('@actions/core');
const submit = require('./src/submit');
const monitor = require('./src/monitor');
const { BlobServiceClient } = require("@azure/storage-blob");
const { DefaultAzureCredential } = require('@azure/identity');
module.exports = {
runCreateTask: submit.run
};
async function run() {
const accountName = core.getInput('azure-storage-account-name');
if (!accountName) {
core.setFailed('Azure Storage accountName not found');
return;
}
const blobServiceClient = new BlobServiceClient(
`https://${accountName}.blob.core.windows.net`,
new DefaultAzureCredential()
);
const containerName = core.getInput('azure-storage-container-name');
const containerClient = blobServiceClient.getContainerClient(containerName);
try {
const subcommand = core.getInput('subcommand');
if (subcommand === 'synchronous') {
const clientWorkflowId = await submit.run(containerClient);
await monitor.run(containerClient, clientWorkflowId);
} else if (subcommand === 'submit') {
const clientWorkflowId = await submit.run(containerClient);
core.setOutput('workflowId', clientWorkflowId);
} else if (subcommand === 'monitor') {
const clientWorkflowId = core.getInput('workflow-id');
await monitor.run(containerClient, clientWorkflowId);
} else {
throw new Error(`Unknown subcommand: ${subcommand}`);
}
} catch (error) {
console.error('Error in main script:', error);
core.setFailed(error.message);
}
}
run();