From ce2b78ed08889842fa14ce7eb60399dc243064a4 Mon Sep 17 00:00:00 2001 From: Leonardo Petrora <29212725+lpetrora@users.noreply.github.com> Date: Fri, 12 Jan 2024 09:23:06 +0100 Subject: [PATCH] Send an e-mail when the nighthly build fails --- .github/workflows/warn.yml | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/warn.yml diff --git a/.github/workflows/warn.yml b/.github/workflows/warn.yml new file mode 100644 index 0000000..2a243e4 --- /dev/null +++ b/.github/workflows/warn.yml @@ -0,0 +1,40 @@ +name: Notify when daily build fails +on: + workflow_run: + workflows: ["CI"] + types: [completed] + branches: [main] + +jobs: + on-failure: + runs-on: ubuntu-latest + if: github.event.workflow_run.conclusion != 'success' && github.event.workflow_run.event == 'schedule' + steps: + - uses: actions/github-script@v6 + id: job-url + with: + script: | + const { data } = await github.rest.actions.listJobsForWorkflowRunAttempt({ + ...context.repo, + run_id: context.runId, + attempt_number: process.env.GITHUB_RUN_ATTEMPT + }); + return data.jobs[0].html_url + result-encoding: string + - uses: adelynx/github-actions-nodemailer@v1.0.3 + with: + host: ${{ secrets.NOTIFICATION_SMTP_SERVER }} + port: 465 + username: '${{ secrets.NOTIFICATION_SMTP_USER }}' + password: '${{ secrets.NOTIFICATION_SMTP_PASSWORD }}' + from: 'Grafana notifications <${{ secrets.NOTIFICATION_SMTP_USER }}>' + to: '${{ secrets.NOTIFICATION_DESTINATION }}' + subject: '🔴 Grafana data source plugin nightly build failed' + + body: | +
The latest Grafana's data source plugin nightly build has failed and needs manual intervention. Additional information:
+Thank you!