-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
73 lines (53 loc) · 2.11 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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 tag = core.getInput('tag');
let initScript = core.getInput('init-script');
let registryLoginServer = core.getInput('registry-login-server');
let registryUser = core.getInput('registry-username');
let registryPass = core.getInput('registry-password');
async function run() {
try {
if (!isPost) {
console.log("Running setup action");
let random = Math.round(10000000000 * Math.random());
let containerName = 'psw-postgres' + random;
core.saveState('containerName', containerName);
console.log("containerName = " + containerName);
await exec.exec(
'pwsh',
[
'-File', setupPs1,
'-ContainerName', containerName,
'-ConnectionStringName', connectionStringName,
'-InitScript', initScript,
'-Tag', tag,
'-RegistryLoginServer', registryLoginServer,
'-RegistryUser', registryUser,
'-RegistryPass', registryPass
]);
} else { // Cleanup
console.log("Running cleanup");
let containerName = core.getState('containerName');
await exec.exec(
'pwsh',
[
'-File', cleanupPs1,
'-ContainerName', containerName,
]);
}
} catch (err) {
core.setFailed(err);
console.log(err);
}
}
run();