/.github/{actions,workflows}: iterating on email using template

This commit is contained in:
Dustin Brown
2021-01-19 13:34:04 -08:00
parent 6be524694c
commit dbdb2533a8
5 changed files with 33 additions and 34 deletions

View File

@@ -5,6 +5,10 @@ inputs:
description: 'aws region'
required: true
default: ''
version:
description: 'dolt version being benchmarked'
required: true
default: ''
dataFile:
required: true
description: 'path to email data file'

View File

@@ -10,6 +10,7 @@ const aws = __webpack_require__(32197);
const fs = __webpack_require__(35747);
const region = core.getInput('region');
const version = core.getInput('version');
const dataFilePath = core.getInput('dataFile');
const CcAddresses = JSON.parse(core.getInput('ccAddresses'));
const ToAddresses = JSON.parse(core.getInput('toAddresses'));
@@ -17,6 +18,11 @@ const ReplyToAddresses = JSON.parse(core.getInput('replyToAddresses'));
const data = fs.readFileSync(dataFilePath, { encoding: 'utf-8' });
const templated = {
version,
results: data,
};
// Set the region
aws.config.update({ region });
@@ -26,28 +32,15 @@ const params = {
CcAddresses,
ToAddresses,
},
Message: { /* required */
Body: { /* required */
Html: {
Charset: "UTF-8",
Data: `This is the first part of the email.\n ${data}`
},
// Text: {
// Charset: "UTF-8",
// Data: "TEXT_FORMAT_BODY"
// }
},
Subject: {
Charset: 'UTF-8',
Data: 'Test email'
}
},
Source: 'dustin@dolthub.com', /* required */
Template: 'PerformanceBenchmarkingReleaseTemplate',
TemplateData: JSON.stringify(templated),
ReplyToAddresses,
};
// Create the promise and SES service object
const sendPromise = new aws.SES({apiVersion: '2010-12-01'}).sendEmail(params).promise();
// const sendPromise = new aws.SES({apiVersion: '2010-12-01'}).sendEmail(params).promise();
const sendPromise = new aws.SES({apiVersion: '2010-12-01'}).sendTemplatedEmail(params).promise();
// Handle promise's fulfilled/rejected states
sendPromise

View File

@@ -3,6 +3,7 @@ const aws = require('aws-sdk');
const fs = require('fs');
const region = core.getInput('region');
const version = core.getInput('version');
const dataFilePath = core.getInput('dataFile');
const CcAddresses = JSON.parse(core.getInput('ccAddresses'));
const ToAddresses = JSON.parse(core.getInput('toAddresses'));
@@ -10,6 +11,11 @@ const ReplyToAddresses = JSON.parse(core.getInput('replyToAddresses'));
const data = fs.readFileSync(dataFilePath, { encoding: 'utf-8' });
const templated = {
version,
results: data,
};
// Set the region
aws.config.update({ region });
@@ -19,28 +25,15 @@ const params = {
CcAddresses,
ToAddresses,
},
Message: { /* required */
Body: { /* required */
Html: {
Charset: "UTF-8",
Data: `This is the first part of the email.\n ${data}`
},
// Text: {
// Charset: "UTF-8",
// Data: "TEXT_FORMAT_BODY"
// }
},
Subject: {
Charset: 'UTF-8',
Data: 'Test email'
}
},
Source: 'dustin@dolthub.com', /* required */
Template: 'PerformanceBenchmarkingReleaseTemplate',
TemplateData: JSON.stringify(templated),
ReplyToAddresses,
};
// Create the promise and SES service object
const sendPromise = new aws.SES({apiVersion: '2010-12-01'}).sendEmail(params).promise();
// const sendPromise = new aws.SES({apiVersion: '2010-12-01'}).sendEmail(params).promise();
const sendPromise = new aws.SES({apiVersion: '2010-12-01'}).sendTemplatedEmail(params).promise();
// Handle promise's fulfilled/rejected states
sendPromise

View File

@@ -0,0 +1,8 @@
{
"Template": {
"TemplateName": "PerformanceBenchmarkingReleaseTemplate",
"SubjectPart": "Performance Benchmarks for {{version}}!",
"HtmlPart": "<h1>Results for {{version}},</h1><div>{{results}}.</div>",
"TextPart": "Results for {{version}},\r\n{{results}}"
}
}

View File

@@ -26,5 +26,6 @@ jobs:
uses: ./.github/actions/ses-email-action
with:
region: us-west-2
version: 'test-version-0.22.11'
toAddresses: '["dustin@dolthub.com"]'
dataFile: ${{ format('{0}/results.log', github.workspace) }}