diff --git a/.github/workflows/testsPython.yml b/.github/workflows/testsPython.yml index 452f71d..21d0285 100644 --- a/.github/workflows/testsPython.yml +++ b/.github/workflows/testsPython.yml @@ -69,11 +69,54 @@ jobs: notifications: needs: python-unit-tests runs-on: ubuntu-latest + if: always() # ← ensures this job runs even when tests fail 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 + - name: Notify Slack on success + if: needs.python-unit-tests.result == 'success' + uses: slackapi/slack-github-action@v1.27.0 + with: + payload: | + { + "text": "*Tests Passed!*", + "attachments": [ + { + "color": "#36A64F", + "fields": [ + { "title": "Repository", "value": "${{ github.repository }}", "short": true }, + { "title": "Branch", "value": "${{ github.ref_name }}", "short": true }, + { "title": "Python Version", "value": "${{ env.python-version }}", "short": true }, + { "title": "Triggered by", "value": "${{ github.actor }}", "short": true }, + { "title": "Commit", "value": "${{ github.sha }}", "short": false }, + { "title": "View Run", "value": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}", "short": false } + ] + } + ] + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK + + - name: Notify Slack on failure + if: needs.python-unit-tests.result != 'success' + uses: slackapi/slack-github-action@v1.27.0 + with: + payload: | + { + "text": "*Tests Failed!*", + "attachments": [ + { + "color": "#FF0000", + "fields": [ + { "title": "Repository", "value": "${{ github.repository }}", "short": true }, + { "title": "Branch", "value": "${{ github.ref_name }}", "short": true }, + { "title": "Python Version", "value": "${{ env.python-version }}", "short": true }, + { "title": "Triggered by", "value": "${{ github.actor }}", "short": true }, + { "title": "Commit", "value": "${{ github.sha }}", "short": false }, + { "title": "View Run", "value": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}", "short": false } + ] + } + ] + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK