diff --git a/.github/workflows/scripts/notify-nightly-failure.js b/.github/workflows/scripts/notify-nightly-failure.js deleted file mode 100644 index 53e47c4fcb7..00000000000 --- a/.github/workflows/scripts/notify-nightly-failure.js +++ /dev/null @@ -1,38 +0,0 @@ -#! /usr/bin/env node - -const sgMail = require("@sendgrid/mail"); -sgMail.setApiKey(process.env.SENDGRID_API_KEY); - -const msg = { - to: `${process.env.SENDGRID_MAIL_TO}`, - from: `${process.env.SENDGRID_MAIL_FROM}`, - subject: "🚨 Nightly Workflow Failed", - text: ` - Nightly Trigger workflow has failed, see details: - - - Workflow: ${process.env.GITHUB_WORKFLOW} - - Repository: ${process.env.GITHUB_REPOSITORY} - - Run Number: ${process.env.GITHUB_RUN_NUMBER} - - Logs: ${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID} - `, - html: ` -

Nightly Trigger workflow has failed, see details:

- - `, -}; - -sgMail - .send(msg) - .then(() => { - console.log("Mail sent successfully"); - console.log("Message details:", msg); - }) - .catch((error) => { - console.error("Error sending email:", error); - process.exit(1); - }); diff --git a/.github/workflows/test-notify-on-failure.yml b/.github/workflows/test-notify-on-failure.yml index 236bfb1503e..7fb3ccdf7ca 100644 --- a/.github/workflows/test-notify-on-failure.yml +++ b/.github/workflows/test-notify-on-failure.yml @@ -11,15 +11,26 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - - name: Make script executable - shell: bash + - name: Write HTML body to file run: | - chmod +x ./.github/workflows/scripts/notify-nightly-failure.js + cat > ./email-body.html <Nightly Trigger workflow has failed, see details: + + EOF - - name: Send failure notification by email - uses: peter-evans/sendgrid-action@v1 - env: - SENDGRID_API_KEY: ${{ secrets.SENDGRID_API_KEY }} - SCRIPT_FILEPATH: ./.github/workflows/scripts/notify-nightly-failure.js - SENDGRID_MAIL_FROM: ${{ secrets.CI_NOTIFICATION_EMAIL_FROM }} - SENDGRID_MAIL_TO: ${{ secrets.CI_NOTIFICATION_EMAIL_TO }} + - name: Send failure notification via Mailgun + uses: dawidd6/action-send-mail@v6 + with: + server_address: ${{ vars.CI_NOTIFICATION_SMTP_SERVER }} + server_port: ${{ vars.CI_NOTIFICATION_SMTP_PORT }} + username: ${{ secrets.CI_NOTIFICATION_SMTP_LOGIN }} + password: ${{ secrets.CI_NOTIFICATION_SMTP_PASSWORD }} + subject: "🚨 Nightly Workflow Failed" + to: ${{ secrets.CI_NOTIFICATION_EMAIL_TO }} + from: ${{ secrets.CI_NOTIFICATION_EMAIL_FROM }} + html_body: file://email-body.html