-
-
Save fra3il/33f03087eada37ca053eab6e81f891f8 to your computer and use it in GitHub Desktop.
[WP/1516] AWS Lambda 는 개뿔.. 하나도 모르겠다고!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Backup script | |
# | |
# Format: YEAR MONTH DAY - HOUR MINUTE SECOND | |
DATE=$(date +%Y%m%d-%H%M%S) | |
# Target file | |
TARGET="../SmartCommit-$DATE.zip" | |
zip -rv $TARGET ./config ./node_modules index.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
function handler(event, context, callback) { | |
console.log('Hello World!'); | |
callback(null, 'Success'); | |
} | |
exports.myHandler = handler; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
function handler(event, context, callback) { | |
console.log('Hello World!'); | |
callback(null, 'Success'); | |
} | |
exports.myHandler = handler; | |
// AWS Lambda 에 올릴 경우, 로컬 테스트를 위한 부분은 제거해야 한다. | |
// 로컬 테스트를 위해 handler 를 호출한다. | |
handler(null, null, function() { | |
console.log(arguments); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cmd": ["node", "$file"], | |
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)", | |
"selector": "source.js", | |
"shell":true, | |
// "encoding": "cp1252", | |
"encoding": "utf8", | |
"windows": | |
{ | |
"cmd": ["taskkill /F /IM node.exe & node", "$file"] | |
}, | |
"linux": | |
{ | |
"cmd": ["killall node; node", "$file"] | |
}, | |
"osx": | |
{ | |
"cmd": ["killall node; node $file"] | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
let https = require('https'); | |
exports.myHandler = (event, context, callback) => { | |
console.log('event type:', typeof event); | |
var commit = event.push.changes[0].commits[0]; | |
var message = commit.message; | |
// var link = commit.links.html.href; | |
// var date = commit.date; | |
sendMessageToSlack(message); | |
callback(null, 'Success'); | |
}; | |
function sendMessageToSlack(message) { | |
var options = { | |
host: 'hooks.slack.com', | |
port: '443', | |
path: '/services/T1CKZQ8BT/B1CJE2FMZ/ny55QfbVy9RmdliD5lXRyLkh', | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/json' | |
} | |
}; | |
var body = { | |
"text": message | |
}; | |
var req = https.request(options, function(res) { | |
console.log('STATUS:', res.statusCode); | |
console.log('HEADERS:', JSON.stringify(res.headers)); | |
res.setEncoding('utf8'); | |
res.on('data', function (data) { | |
console.log('BODY:', data); | |
}); | |
res.on('end', function() { | |
console.log('END'); | |
}); | |
}); | |
req.on('error', function(error) { | |
console.log('ERROR:', error.message); | |
}); | |
// write data to request body | |
req.write(JSON.stringify(body)); | |
req.end(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment