From 78b0e470f3055d08c51bfe0942bf61dd9ddbd9de Mon Sep 17 00:00:00 2001 From: Leszek Manicki Date: Thu, 12 Sep 2024 21:24:34 +0200 Subject: [PATCH 1/2] Send email on github actions CI test job failures --- .github/workflows/push.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index 1056cde..9b1559b 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -26,3 +26,17 @@ jobs: run: composer install --prefer-source --no-progress - name: Run test suite run: composer run-script ci + - name: Send mail on failure + if: ${{ failure() }} + uses: dawidd6/action-send-mail@v3 + with: + server_address: smtp.gmail.com + server_port: 465 + username: ${{secrets.CI_MAIL_USERNAME}} + password: ${{secrets.CI_MAIL_PASSWORD}} + to: wikidata-ci-status@wikimedia.de + from: ${{ github.repository }} CI + subject: CI job failed for ${{ github.repository }} + html_body: | + CI workflow ${{ github.workflow }} failed! + The failed job can be found in here From 76f5e7b4e1d68d008ebad283bfc577af4d4be995 Mon Sep 17 00:00:00 2001 From: Leszek Manicki Date: Thu, 19 Sep 2024 11:17:03 +0200 Subject: [PATCH 2/2] Use markdown to define "body" content of CI failure emails --- .github/workflows/ci_failure_email.md.tmpl | 3 +++ .github/workflows/push.yaml | 14 +++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/ci_failure_email.md.tmpl diff --git a/.github/workflows/ci_failure_email.md.tmpl b/.github/workflows/ci_failure_email.md.tmpl new file mode 100644 index 0000000..322186b --- /dev/null +++ b/.github/workflows/ci_failure_email.md.tmpl @@ -0,0 +1,3 @@ +CI workflow ${WORKFLOW} failed! + +The failed job can be found in [here](${SERVER_URL}/${REPOSITORY}/actions/runs/${RUN_ID}). diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index 9b1559b..88b4c9c 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -14,6 +14,15 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php_version }} + - uses: nowactions/envsubst@v1 + with: + input: ${{ github.workspace }}/.github/workflows/ci_failure_email.md.tmpl + output: ${{ github.workspace }}/.github/workflows/ci_failure_email.md + env: + WORKFLOW: ${{ github.workflow }} + SERVER_URL: ${{ github.server_url }} + REPOSITORY: ${{ github.repository }} + RUN_ID: ${{ github.run_id }} - name: Validate composer.json and composer.lock run: composer validate --strict - name: Cache Composer packages @@ -37,6 +46,5 @@ jobs: to: wikidata-ci-status@wikimedia.de from: ${{ github.repository }} CI subject: CI job failed for ${{ github.repository }} - html_body: | - CI workflow ${{ github.workflow }} failed! - The failed job can be found in here + convert_markdown: true + html_body: file://${{ github.workspace }}/.github/workflows/ci_failure_email.md