-
Notifications
You must be signed in to change notification settings - Fork 15
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 #140 from wmde/github-actions-email-on-failure
GitHub actions email on failure
- Loading branch information
Showing
2 changed files
with
25 additions
and
0 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
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}). |
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 |
---|---|---|
|
@@ -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 | ||
|
@@ -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 |