@ossy/deployment-tools 0.0.79 → 0.0.80
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ossy/deployment-tools",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.80",
|
|
4
4
|
"description": "Collection of scripts and tools to aid deployment of containers and static files to Amazon Web Services through GitHub Actions",
|
|
5
5
|
"source": "./src/index.js",
|
|
6
6
|
"main": "./src/index.js",
|
package/src/deploy/cli.js
CHANGED
|
@@ -38,10 +38,41 @@ const deploy = options => {
|
|
|
38
38
|
})
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
const deployAll = options => {
|
|
42
|
+
logInfo({ message: '[CLI] Running deploy-all command' })
|
|
43
|
+
|
|
44
|
+
const parsedArgs = arg({
|
|
45
|
+
'--username': String,
|
|
46
|
+
'-u': '--username',
|
|
47
|
+
|
|
48
|
+
'--authentication': String,
|
|
49
|
+
'--a': '--authentication',
|
|
50
|
+
|
|
51
|
+
'--platform': String,
|
|
52
|
+
'-p': '--platform',
|
|
53
|
+
|
|
54
|
+
'--platforms-path': String,
|
|
55
|
+
'-pp': '--platforms-path',
|
|
56
|
+
|
|
57
|
+
'--deployments-path': String,
|
|
58
|
+
'-dp': '--deployments-path',
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
}, { argv: options })
|
|
62
|
+
|
|
63
|
+
PlatformDeploymentService.deployAll({
|
|
64
|
+
username: parsedArgs['--username'],
|
|
65
|
+
authentication: parsedArgs['--authentication'],
|
|
66
|
+
targetPlatform: parsedArgs['--platform'],
|
|
67
|
+
pathToPlatformTemplates: parsedArgs['--platforms-path'],
|
|
68
|
+
pathToDeploymentTemplates: parsedArgs['--deployments-path']
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
|
|
41
72
|
module.exports = {
|
|
42
73
|
handler: ([command, ...options]) => {
|
|
43
74
|
!!command
|
|
44
|
-
? { deploy }[command](options)
|
|
75
|
+
? { deploy, 'deploy-all': deployAll }[command](options)
|
|
45
76
|
: logError({ message: 'No command provided' })
|
|
46
77
|
}
|
|
47
78
|
}
|
|
@@ -63,6 +63,60 @@ class PlatformDeploymentService {
|
|
|
63
63
|
.catch(error => logError({ message: '[PlatformDeploymentService] Could not send deployment request', error }))
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
static deployAll({
|
|
67
|
+
username,
|
|
68
|
+
authentication,
|
|
69
|
+
targetDomain,
|
|
70
|
+
targetPlatform,
|
|
71
|
+
pathToPlatformTemplates,
|
|
72
|
+
pathToDeploymentTemplates
|
|
73
|
+
}) {
|
|
74
|
+
|
|
75
|
+
return Promise.all([
|
|
76
|
+
DeploymentTemplateService.readFromFiles(pathToDeploymentTemplates),
|
|
77
|
+
PlatformTemplateService.readFromFile(pathToPlatformTemplates)
|
|
78
|
+
.then(templates => templates.map(PlatformConfigService.from))
|
|
79
|
+
])
|
|
80
|
+
.then(([deploymentTemplates, platformConfigs]) => {
|
|
81
|
+
|
|
82
|
+
const platformConfig = platformConfigs.find(({ platformName }) => platformName === targetPlatform)
|
|
83
|
+
const deploymentTemplatesForTargetPlatform = deploymentTemplates[targetPlatform] || []
|
|
84
|
+
|
|
85
|
+
if (!platformConfig) {
|
|
86
|
+
logError({ message: `[PlatformDeploymentService] Could not find a platform named ${targetPlatform}` })
|
|
87
|
+
return Promise.reject()
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (deploymentTemplatesForTargetPlatform.length === 0) {
|
|
91
|
+
logError({ message: `[PlatformDeploymentService] Could not find a deployment template for ${targetDomain} in ${targetPlatform}` })
|
|
92
|
+
return Promise.reject()
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'
|
|
96
|
+
|
|
97
|
+
return deploymentTemplatesForTargetPlatform.map(deploymentTemplate => {
|
|
98
|
+
if (deploymentTemplate.type === SupportedDeploymentTypes.Container) {
|
|
99
|
+
|
|
100
|
+
const caddyConfig = CaddyConfigService.createConfig(platformConfig, deploymentTemplatesForTargetPlatform)
|
|
101
|
+
|
|
102
|
+
const deploymentRequest = {
|
|
103
|
+
...deploymentTemplate,
|
|
104
|
+
username: username,
|
|
105
|
+
authentication: authentication,
|
|
106
|
+
caddyConfig
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return DeploymentQueueService.sendDeploymentRequest(platformConfig, deploymentRequest)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
logError({ message: `[PlatformDeploymentService] Unsupported deployment type of ${deploymentTemplate.type}` })
|
|
113
|
+
return Promise.reject()
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
})
|
|
117
|
+
.catch(error => logError({ message: '[PlatformDeploymentService] Could not send deployment request', error }))
|
|
118
|
+
}
|
|
119
|
+
|
|
66
120
|
}
|
|
67
121
|
|
|
68
122
|
module.exports = {
|
|
@@ -33,7 +33,8 @@ class DockerService {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
static removeImage(deploymentRequest) {
|
|
36
|
-
const
|
|
36
|
+
const { registry, image } = deploymentRequest
|
|
37
|
+
const name = !!registry ? `${registry}/${image}` : image
|
|
37
38
|
logInfo({ message: `[DockerService] Removing image ${name}` })
|
|
38
39
|
return exec(`docker image rm -f ${name}`)
|
|
39
40
|
.catch(() => {}) // no worries if container isn't there
|