-
Notifications
You must be signed in to change notification settings - Fork 14
/
index.js
43 lines (36 loc) · 1.09 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const core = require('@actions/core');
const github = require('@actions/github');
const fs = require('fs');
const AWS = require('aws-sdk');
try {
const functionName = core.getInput('function-name');
const package = core.getInput('package');
const AWS_SECRET_KEY = core.getInput('AWS_SECRET_KEY');
const AWS_SECRET_ID = core.getInput('AWS_SECRET_ID');
const AWS_REGION = core.getInput('AWS_REGION');
console.log(`Updating Function Name ${functionName} with ${package}!`);
var zipBuffer = fs.readFileSync(`./${package}`);
core.debug('Package put into memory buffer');
const lambda = new AWS.Lambda({
apiVersion: '2015-03-31',
region: AWS_REGION,
secretAccessKey: AWS_SECRET_KEY,
accessKeyId: AWS_SECRET_ID,
maxRetries: 3,
sslEnabled: true,
logger: console,
});
const params = {
FunctionName: functionName,
Publish: false,
ZipFile: zipBuffer,
};
lambda.updateFunctionCode(params, err => {
if (err) {
console.error(err);
core.setFailed(err)
}
});
} catch (error) {
core.setFailed(error.message);
}