Skip to content

Commit

Permalink
Merge pull request #140 from wmde/github-actions-email-on-failure
Browse files Browse the repository at this point in the history
GitHub actions email on failure
  • Loading branch information
manicki authored Nov 29, 2024
2 parents d8fd2fb + 76f5e7b commit 135a560
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci_failure_email.md.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CI workflow ${WORKFLOW} failed!

The failed job can be found in [here](${SERVER_URL}/${REPOSITORY}/actions/runs/${RUN_ID}).
22 changes: 22 additions & 0 deletions .github/workflows/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -26,3 +35,16 @@ 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: [email protected]
from: ${{ github.repository }} CI
subject: CI job failed for ${{ github.repository }}
convert_markdown: true
html_body: file://${{ github.workspace }}/.github/workflows/ci_failure_email.md

0 comments on commit 135a560

Please sign in to comment.