Skip to content
Merged

cicd #222

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/cd_dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ jobs:
envkey_TINYPEN: ${{ secrets.TINYPENDEV }}
envkey_AUDIENCE: ${{ secrets.AUDIENCE }}
envkey_DOMAIN: ${{ secrets.DOMAIN }}
envkey_TPEN_SUPPORT_EMAIL: ${{ secrets.TPEN_SUPPORT_EMAIL }}
envkey_SMTP_HOST: ${{ secrets.SMTP_HOST }}
envkey_SMTP_PORT: ${{ secrets.SMTP_PORT }}
envkey_TPEN_EMAIL_CC: ${{ secrets.TPEN_EMAIL_CC }}
- name: Setup Node.js
uses: actions/setup-node@master
with:
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/cd_prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ jobs:
envkey_TINYPEN: ${{ secrets.TINYPEN }}
envkey_AUDIENCE: ${{ secrets.AUDIENCE }}
envkey_DOMAIN: ${{ secrets.DOMAIN }}
envkey_TPEN_SUPPORT_EMAIL: ${{ secrets.TPEN_SUPPORT_EMAIL }}
envkey_SMTP_HOST: ${{ secrets.SMTP_HOST }}
envkey_SMTP_PORT: ${{ secrets.SMTP_PORT }}
envkey_TPEN_EMAIL_CC: ${{ secrets.TPEN_EMAIL_CC }}
- name: Setup Node.js
uses: actions/setup-node@master
with:
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/ci_dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ jobs:
envkey_TINYPEN: ${{ secrets.TINYPENDEV }}
envkey_AUDIENCE: ${{ secrets.AUDIENCE }}
envkey_DOMAIN: ${{ secrets.DOMAIN }}
envkey_TPEN_SUPPORT_EMAIL: ${{ secrets.TPEN_SUPPORT_EMAIL }}
envkey_SMTP_HOST: ${{ secrets.SMTP_HOST }}
envkey_SMTP_PORT: ${{ secrets.SMTP_PORT }}
envkey_TPEN_EMAIL_CC: ${{ secrets.TPEN_EMAIL_CC }}
- name: Setup Node.js
uses: actions/setup-node@master
with:
Expand All @@ -47,4 +51,4 @@ jobs:
run: |
npm install
npm run E2Etests


6 changes: 5 additions & 1 deletion .github/workflows/ci_prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ jobs:
envkey_TINYPEN: ${{ secrets.TINYPEN }}
envkey_AUDIENCE: ${{ secrets.AUDIENCE }}
envkey_DOMAIN: ${{ secrets.DOMAIN }}
envkey_TPEN_SUPPORT_EMAIL: ${{ secrets.TPEN_SUPPORT_EMAIL }}
envkey_SMTP_HOST: ${{ secrets.SMTP_HOST }}
envkey_SMTP_PORT: ${{ secrets.SMTP_PORT }}
envkey_TPEN_EMAIL_CC: ${{ secrets.TPEN_EMAIL_CC }}
- name: Setup Node.js
uses: actions/setup-node@master
with:
Expand All @@ -47,4 +51,4 @@ jobs:
run: |
npm install
npm run E2Etests


25 changes: 25 additions & 0 deletions utilities/mailer/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,37 @@ export const sendMail = async (email, subject, message) => {
htmlTemplate = htmlTemplate.replace("{{subject}}", subject)
htmlTemplate = htmlTemplate.replace("{{messageBody}}", message)

// Stop execution if any of the required environment variables are not set
const requiredEnvVars = [
"SMTP_HOST",
"SMTP_PORT",
"TPEN_SUPPORT_EMAIL",
"TPEN_EMAIL_CC"
]

requiredEnvVars.forEach(varName => {
if (!process.env[varName]) {
return {
status: 500,
message: `${varName} environment variable is not set.`
}
}
})

try {
const transporter = nodemailer.createTransport({
host: process.env.SMTP_HOST,
port: process.env.SMTP_PORT,
})

transporter.verify((error, success) => {
if (error) {
console.log("Error in SMTP configuration: ", error)
return {status: 500, message: error.toString()}
}
console.log("Server is ready to take our messages")
})

const mailOptions = {
from: process.env.TPEN_SUPPORT_EMAIL,
to: email,
Expand Down
Loading