@ossy/deployment-tools 0.0.55 → 0.0.56

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.55",
3
+ "version": "0.0.56",
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",
@@ -1,5 +1,5 @@
1
1
  const { exec: execBash } = require('child_process')
2
- const { logInfo, logDebug } = require('../log')
2
+ const { logInfo, logDebug, logErrorAndReject } = require('../log')
3
3
 
4
4
  const exec = command => new Promise((resolve, reject) => {
5
5
  execBash(command, (error, stdout, stderr) => {
@@ -32,6 +32,7 @@ class DockerService {
32
32
  const envsAsString = Object.entries(env || {}).reduce((envs, [name, value]) => `${envs} --env ${name}=${value}`, '')
33
33
  logInfo({ message: `[DockerService] Running docker start for image with the name of ${name} with port mapping ${hostPort}:${containerPort} and source ${imageUrl}` })
34
34
  return exec(`docker run -d -p ${hostPort}:${containerPort} --name=${name} --network=${platformConfig.ciDockerNetworkName} --network-alias=${name} --rm ${envsAsString} ${imageUrl}`)
35
+ .cath(logErrorAndReject(`[DockerService] Could not start container ${image}`))
35
36
  }
36
37
 
37
38
  static resolveCredentials({ registry, username, authentication }) {
@@ -41,9 +42,10 @@ class DockerService {
41
42
  ? logInfo({ message: '[DockerService] Docker credentials provided, logging in to private repository' })
42
43
  : logInfo({ message: '[DockerService] No docker credentials provided, assuming image is publicly hosted' })
43
44
 
44
- return shouldAuthenticate
45
- ? exec(`docker login ${registry} -u ${username} -p ${authentication}`)
46
- : Promise.resolve()
45
+ return !shouldAuthenticate
46
+ ? Promise.resolve()
47
+ : exec(`docker login ${registry} -u ${username} -p ${authentication}`)
48
+ .cath(logErrorAndReject(`[DockerService] Could not authenticate with ${registry}`))
47
49
  }
48
50
 
49
51
  static deploy(platformConfig, deploymentRequest) {
package/src/log.js CHANGED
@@ -33,8 +33,14 @@ const logDebug = logInput => {
33
33
  logInput.data && log('\n[Debug data]:', logInput.data, '\n')
34
34
  }
35
35
 
36
+ const logErrorAndReject = message => error => {
37
+ logError({ message, error })
38
+ return Promise.reject(error)
39
+ }
40
+
36
41
  module.exports = {
37
42
  logInfo,
38
43
  logError,
44
+ logErrorAndReject,
39
45
  logDebug
40
46
  }
@@ -24,7 +24,7 @@ class PlatformServerService {
24
24
  platformConfig,
25
25
  deploymentRequest => {
26
26
  DockerService.deploy(platformConfig, deploymentRequest)
27
- CaddyService.addDeployment(platformConfig, deploymentRequest)
27
+ .then(() => CaddyService.addDeployment(platformConfig, deploymentRequest))
28
28
  return Promise.resolve()
29
29
  }
30
30
  )