Skip to content

Commit

Permalink
Merge pull request #3 from IndraGunawan/throw-error
Browse files Browse the repository at this point in the history
handle response failures
  • Loading branch information
abronin authored Jun 14, 2022
2 parents e40f580 + 8df6755 commit 38afa46
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 40 deletions.
46 changes: 26 additions & 20 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,33 +32,39 @@ async function run() {
core.info(`${err.message}, no action`)
return
}

core.setFailed(err.message)
} else {
let image = result.image
core.info(`Image tagged: ${image.repositoryName}:${image.imageId.imageTag}`)
core.debug(result)
}

let image = result.image
core.info(`Image tagged: ${image.repositoryName}:${image.imageId.imageTag}`)
core.debug(result)
}

let getImageCallback = function (err, result) {
if (err) {
core.setFailed(err)
} else {
let image = result.images[0]
core.info(`Image found: ${image.repositoryName}:${image.imageId.imageTag}`)
core.debug(image)
newTags.forEach(function (tag) {
ecr.putImage(
{
registryId: image.registryId,
repositoryName: image.repositoryName, /* required */
imageManifest: image.imageManifest, /* required */
imageTag: tag,
},
putImageCallback
)
})
core.setFailed(err.message)
}

if (result.failures.length > 0) {
const failure = result.failures[0]
core.setFailed(`${failure.failureCode}: ${failure.failureReason} for tag ${failure.imageId.imageTag}`)
}

let image = result.images[0]
core.info(`Image found: ${image.repositoryName}:${image.imageId.imageTag}`)
core.debug(image)
newTags.forEach(function (tag) {
ecr.putImage(
{
registryId: image.registryId,
repositoryName: image.repositoryName, /* required */
imageManifest: image.imageManifest, /* required */
imageTag: tag,
},
putImageCallback
)
})
}

ecr.batchGetImage(getImageParams, getImageCallback);
Expand Down
46 changes: 26 additions & 20 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,39 @@ async function run() {
core.info(`${err.message}, no action`)
return
}

core.setFailed(err.message)
} else {
let image = result.image
core.info(`Image tagged: ${image.repositoryName}:${image.imageId.imageTag}`)
core.debug(result)
}

let image = result.image
core.info(`Image tagged: ${image.repositoryName}:${image.imageId.imageTag}`)
core.debug(result)
}

let getImageCallback = function (err, result) {
if (err) {
core.setFailed(err)
} else {
let image = result.images[0]
core.info(`Image found: ${image.repositoryName}:${image.imageId.imageTag}`)
core.debug(image)
newTags.forEach(function (tag) {
ecr.putImage(
{
registryId: image.registryId,
repositoryName: image.repositoryName, /* required */
imageManifest: image.imageManifest, /* required */
imageTag: tag,
},
putImageCallback
)
})
core.setFailed(err.message)
}

if (result.failures.length > 0) {
const failure = result.failures[0]
core.setFailed(`${failure.failureCode}: ${failure.failureReason} for tag ${failure.imageId.imageTag}`)
}

let image = result.images[0]
core.info(`Image found: ${image.repositoryName}:${image.imageId.imageTag}`)
core.debug(image)
newTags.forEach(function (tag) {
ecr.putImage(
{
registryId: image.registryId,
repositoryName: image.repositoryName, /* required */
imageManifest: image.imageManifest, /* required */
imageTag: tag,
},
putImageCallback
)
})
}

ecr.batchGetImage(getImageParams, getImageCallback);
Expand Down

0 comments on commit 38afa46

Please sign in to comment.