-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
69 lines (49 loc) · 1.88 KB
/
index.js
File metadata and controls
69 lines (49 loc) · 1.88 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
const path = require('path');
const core = require('@actions/core');
const exec = require('@actions/exec');
const setupPs1 = path.resolve(__dirname, '../setup.ps1');
const cleanupPs1 = path.resolve(__dirname, '../cleanup.ps1');
console.log('Setup path: ' + setupPs1);
console.log('Cleanup path: ' + cleanupPs1);
// Only one endpoint, so determine if this is the post action, and set it true so that
// the next time we're executed, it goes to the post action
let isPost = core.getState('IsPost');
core.saveState('IsPost', true);
let connectionStringName = core.getInput('connection-string-name');
let azureCredentials = core.getInput('azure-credentials');
let tagName = core.getInput('tag');
let api = core.getInput('api');
if (api !== 'Sql' && api !== 'Table') {
core.setFailed("Parameter 'api' must be either 'Sql' or 'Table'. Default is 'Sql'.");
return;
}
async function run() {
try {
if (!isPost) {
console.log("Running setup action");
let cosmosName = 'psw-cosmosdb-' + Math.round(10000000000 * Math.random());
core.saveState('CosmosName', cosmosName);
console.log("CosmosName = " + cosmosName);
await exec.exec('pwsh', [
'-File', setupPs1,
'-cosmosName', cosmosName,
'-connectionStringName', connectionStringName,
'-tagName', tagName,
'-api', api,
'-azureCredentials', azureCredentials
]);
} else { // Cleanup
console.log("Running cleanup");
let cosmosName = core.getState('CosmosName');
await exec.exec('pwsh', [
'-File', cleanupPs1,
'-cosmosName', cosmosName,
'-azureCredentials', azureCredentials
]);
}
} catch (err) {
core.setFailed(err);
console.log(err);
}
}
run();