forked from rrainn/dynamodb-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
20 lines (17 loc) · 942 Bytes
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
const core = require("@actions/core");
const exec = require("@actions/exec");
const settings = ["port", "dbPath", "sharedDb", "cors", "delayTransientStatuses", "optimizeDbBeforeStartup", "version"].reduce((obj, key) => {
obj[key] = core.getInput(key);
return obj;
}, {});
(async function (){
const extraArguments = [
settings.dbPath ? `-dbPath ${settings.dbPath}` : "-inMemory",
settings.sharedDb ? "-sharedDb" : null,
settings.cors ? `-cors ${settings.cors}` : null,
settings.delayTransientStatuses ? `-delayTransientStatuses` : null,
settings.optimizeDbBeforeStartup ? `-optimizeDbBeforeStartup` : null
settings.version ? settings.version : "latest"
].filter((a) => Boolean(a)).join(" ");
await exec.exec(`sudo docker run --name dynamodb -d -p ${settings.port}:${settings.port} amazon/dynamodb-local:${settings.version} -jar DynamoDBLocal.jar -port ${settings.port}${extraArguments ? ` ${extraArguments}` : ""}`);
})();