Skip to content

Commit

Permalink
ensure we wait for lambda code to be updated
Browse files Browse the repository at this point in the history
  • Loading branch information
mydea committed Nov 22, 2021
1 parent bbd175b commit d6d7665
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const core = require("@actions/core");
const fs = require("fs");
const AWS = require("aws-sdk");

try {
async function run() {
// Get all parameters
const ZIP = core.getInput("ZIP");
const FUNCTION_NAME = core.getInput("FUNCTION_NAME");
Expand Down Expand Up @@ -55,12 +55,7 @@ try {
ZipFile: zipBuffer,
};

lambda.updateFunctionCode(uploadParams, (err) => {
if (!!err) {
core.error(err.message);
core.setFailed(err);
}
});
await lambda.updateFunctionCode(uploadParams).promise();

let configParams = {
FunctionName: FUNCTION_NAME,
Expand Down Expand Up @@ -89,14 +84,21 @@ try {
}

if (Object.keys(configParams).length > 1) {
lambda.updateFunctionConfiguration(configParams, (err) => {
if (!!err) {
core.error(err.message);
core.setFailed(err);
}
});
await lambda
.waitFor("functionUpdated", {
FunctionName: FUNCTION_NAME,
})
.promise();

await lambda.updateFunctionConfiguration(configParams).promise();
}
} catch (error) {
core.error(error.message);
core.setFailed(error.message);
}

(async function () {
try {
await run();
} catch (error) {
core.error(error.message);
core.setFailed(error.message);
}
})();

0 comments on commit d6d7665

Please sign in to comment.