-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #380 from lincc-frameworks/issue/312/failure-emails
Send email on failure
- Loading branch information
Showing
3 changed files
with
75 additions
and
9 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,12 +42,44 @@ jobs: | |
run: | | ||
python -m pytest | ||
{%- if 'email' in failure_notification %} | ||
- name: Send failure email | ||
- name: Send status to author's email | ||
if: {% raw %}${{ failure() }} && github.event_name != 'workflow_dispatch' }}{% endraw %} # Only email if the workflow failed and was not manually started. Customize this as necessary. | ||
uses: dawidd6/action-send-mail@v3 | ||
with: | ||
# Required mail server address if not connection_url: | ||
server_address: smtp.gmail.com | ||
# Server port: (uses TLS by default if server_port is 465) | ||
server_port: 465 | ||
|
||
# Mail server username: | ||
username: {% raw %}${{secrets.MAIL_USERNAME}}{% endraw %} | ||
# Mail server password: | ||
password: {% raw %}${{secrets.MAIL_PASSWORD}}{% endraw %} | ||
# Required recipients' addresses: | ||
to: {{ author_email }} | ||
|
||
# Required mail subject: | ||
subject: {% raw %}Smoke test ${{ job.status }} in ${{github.repository}}{% endraw %} | ||
# Required sender full name: | ||
from: GitHub Actions Report | ||
# Optional body: | ||
html_body: {% raw %}| | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
<h3>Smoke test ${{ job.status }}</h3> | ||
<p>The smoke test in <b>${{ github.repository }}</b> has completed with result: <b>${{ job.status }}</b></p> | ||
<p><a href="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"> | ||
${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | ||
</a></p> | ||
</body> | ||
</html> | ||
{% endraw %} | ||
{%- endif %} | ||
{%- if 'slack' in failure_notification %} | ||
{%- raw %} | ||
- name: Send status to Slack app | ||
if: ${{ failure() && github.event_name != 'workflow_dispatch' }} # Only post if the workflow failed and was not manually started. Customize this as necessary./ | ||
if: {% raw %}${{ failure() && github.event_name != 'workflow_dispatch' }}{% endraw %} # Only post if the workflow failed and was not manually started. Customize this as necessary. | ||
id: slack | ||
uses: slackapi/[email protected] | ||
with: | ||
|
@@ -84,5 +116,4 @@ jobs: | |
env: | ||
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # Here is where the webhook URL is provided | ||
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK | ||
{%- endraw %} | ||
{%- endif %} | ||
{%- endif %} |