Skip to content

Commit

Permalink
Invoke lambda with v3
Browse files Browse the repository at this point in the history
  • Loading branch information
tarikdem committed Apr 3, 2024
1 parent 63e6976 commit e0aa81e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 28 deletions.
30 changes: 16 additions & 14 deletions code-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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}`);

Expand Down
30 changes: 16 additions & 14 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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}`);

Expand Down

0 comments on commit e0aa81e

Please sign in to comment.