-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.mjs
More file actions
65 lines (53 loc) · 2.2 KB
/
Copy pathindex.mjs
File metadata and controls
65 lines (53 loc) · 2.2 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
import * as path from 'node:path';
import * as url from 'node:url';
import * as core from '@actions/core';
import * as exec from '@actions/exec';
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
const setupPs1 = path.resolve(__dirname, '../setup.ps1');
const cleanupPs1 = path.resolve(__dirname, '../cleanup.ps1');
// Only one entry point, 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.
const isPost = core.getState('IsPost');
core.saveState('IsPost', true);
const connectionStringName = core.getInput('connection-string-name');
const databaseName = core.getInput('database-name');
const username = core.getInput('username');
const imageTag = core.getInput('image-tag');
const initScript = core.getInput('init-script');
const registryLoginServer = core.getInput('registry-login-server');
const registryUser = core.getInput('registry-username');
const registryPass = core.getInput('registry-password');
async function run() {
try {
if (!isPost) {
console.log('Running setup action');
const random = Math.round(10000000000 * Math.random());
const containerName = 'setup-mysql' + random;
core.saveState('containerName', containerName);
console.log('containerName = ' + containerName);
await exec.exec('pwsh', [
'-File', setupPs1,
'-ContainerName', containerName,
'-ConnectionStringName', connectionStringName,
'-DatabaseName', databaseName,
'-Username', username,
'-ImageTag', imageTag,
'-InitScript', initScript,
'-RegistryLoginServer', registryLoginServer,
'-RegistryUser', registryUser,
'-RegistryPass', registryPass
]);
} else {
console.log('Running cleanup');
const containerName = core.getState('containerName');
await exec.exec('pwsh', [
'-File', cleanupPs1,
'-ContainerName', containerName,
]);
}
} catch (err) {
core.setFailed(err);
console.log(err);
}
}
run();