diff --git a/code-build.js b/code-build.js index c178a2b..fdeab56 100644 --- a/code-build.js +++ b/code-build.js @@ -6,7 +6,7 @@ const github = require("@actions/github"); const { CloudWatchLogs } = require("@aws-sdk/client-cloudwatch-logs"); const { CodeBuild } = require("@aws-sdk/client-codebuild"); -const { Lambda } = require("@aws-sdk/client-lambda"); +const { Lambda, InvokeCommand } = require("@aws-sdk/client-lambda"); const assert = require("assert"); @@ -42,19 +42,21 @@ async function build(sdk, params, config) { // Invoke the lambda to start the build const buildTime = (Date.now() / 1000).toString(); const imageTag = `${params.sourceVersion}-${Math.floor(buildTime)}`; - const lambdaParams = { - FunctionName: "GeneralDockerBuildPipelineLambdaFunction", - Payload: JSON.stringify({ - owner: params.owner, - repo: params.repo, - branch: params.branch, - sourceVersion: params.sourceVersion, - reproducible: params.reproducible, - imageTag, - }), - }; - const response = await sdk.lambda.invoke(lambdaParams); - const start = JSON.parse(JSON.parse(response.Payload)); + const { Payload } = await sdk.lambda.invoke( + new InvokeCommand({ + FunctionName: "GeneralDockerBuildPipelineLambdaFunction", + Payload: JSON.stringify({ + owner: params.owner, + repo: params.repo, + branch: params.branch, + sourceVersion: params.sourceVersion, + reproducible: params.reproducible, + imageTag, + }), + }) + ); + const start = Buffer.from(Payload).toString(); + console.log(start); await core.notice(`Built image tag: ${imageTag}`); diff --git a/dist/index.js b/dist/index.js index f853425..494dd2f 100644 --- a/dist/index.js +++ b/dist/index.js @@ -14,7 +14,7 @@ const { CloudWatchLogs } = __nccwpck_require__(1573); const { CodeBuild } = __nccwpck_require__(6872); - const { Lambda } = __nccwpck_require__(6584); + const { Lambda, InvokeCommand } = __nccwpck_require__(6584); const assert = __nccwpck_require__(9491); @@ -54,19 +54,21 @@ // Invoke the lambda to start the build const buildTime = (Date.now() / 1000).toString(); const imageTag = `${params.sourceVersion}-${Math.floor(buildTime)}`; - const lambdaParams = { - FunctionName: "GeneralDockerBuildPipelineLambdaFunction", - Payload: JSON.stringify({ - owner: params.owner, - repo: params.repo, - branch: params.branch, - sourceVersion: params.sourceVersion, - reproducible: params.reproducible, - imageTag, - }), - }; - const response = await sdk.lambda.invoke(lambdaParams); - const start = JSON.parse(JSON.parse(response.Payload)); + const { Payload } = await sdk.lambda.invoke( + new InvokeCommand({ + FunctionName: "GeneralDockerBuildPipelineLambdaFunction", + Payload: JSON.stringify({ + owner: params.owner, + repo: params.repo, + branch: params.branch, + sourceVersion: params.sourceVersion, + reproducible: params.reproducible, + imageTag, + }), + }) + ); + const start = Buffer.from(Payload).toString(); + console.log(start); await core.notice(`Built image tag: ${imageTag}`);