diff --git a/.github/workflows/test-email.yml b/.github/workflows/test-email.yml new file mode 100644 index 0000000..6567387 --- /dev/null +++ b/.github/workflows/test-email.yml @@ -0,0 +1,22 @@ +name: Test Email Notification + +on: + workflow_dispatch: # run manually from Actions tab + +jobs: + send-test-email: + runs-on: ubuntu-latest + steps: + - name: Send test email + uses: dawidd6/action-send-mail@v3 + with: + server_address: ${{ secrets.SMTP_SERVER }} + server_port: ${{ secrets.SMTP_PORT }} + username: ${{ secrets.SMTP_USERNAME }} + password: ${{ secrets.SMTP_PASSWORD }} + subject: "GitHub Actions Email Test" + to: ${{ secrets.NOTIFY_EMAIL_TO }} + from: ${{ secrets.NOTIFY_EMAIL_FROM }} + body: | + This is a test email sent from GitHub Actions. + If you received this, your SMTP settings are correct. diff --git a/.github/workflows/testsPython.yml b/.github/workflows/testsPython.yml index 452f71d..0741639 100644 --- a/.github/workflows/testsPython.yml +++ b/.github/workflows/testsPython.yml @@ -67,13 +67,46 @@ jobs: # is scaffolded to facilitate sending notifications based # on the test results. notifications: - needs: python-unit-tests - runs-on: ubuntu-latest - steps: - - name: Notify on test results - run: | - if [ "${{ needs.python-unit-tests.result }}" == "success" ]; then - echo "success notifications go here" - else - echo "failure notifications go here" - fi + needs: python-unit-tests + if: always() + runs-on: ubuntu-latest + steps: + - name: Send success email + if: ${{ needs.python-unit-tests.result == 'success' }} + uses: dawidd6/action-send-mail@v3 + with: + server_address: ${{ secrets.SMTP_SERVER }} + server_port: ${{ secrets.SMTP_PORT }} + username: ${{ secrets.SMTP_USERNAME }} + password: ${{ secrets.SMTP_PASSWORD }} + subject: "Python Unit Tests Passed" + to: ${{ secrets.NOTIFY_EMAIL_TO }} + from: ${{ secrets.NOTIFY_EMAIL_FROM }} + body: | + 🎉 Python unit tests succeeded! + + Workflow: Python Unit Tests + Status: SUCCESS + Branch: ${{ github.ref }} + Commit: ${{ github.sha }} + + - name: Send failure email + if: ${{ needs.python-unit-tests.result != 'success' }} + uses: dawidd6/action-send-mail@v3 + with: + server_address: ${{ secrets.SMTP_SERVER }} + server_port: ${{ secrets.SMTP_PORT }} + username: ${{ secrets.SMTP_USERNAME }} + password: ${{ secrets.SMTP_PASSWORD }} + subject: "Python Unit Tests FAILED" + to: ${{ secrets.NOTIFY_EMAIL_TO }} + from: ${{ secrets.NOTIFY_EMAIL_FROM }} + body: | + ❌ Python unit tests failed. + + Workflow: Python Unit Tests + Status: FAILURE + Branch: ${{ github.ref }} + Commit: ${{ github.sha }} + + Check the GitHub Actions logs for details.