From d2398b57983900168d296dd0154902a2f4718308 Mon Sep 17 00:00:00 2001 From: Ray Huang Date: Fri, 20 Feb 2026 22:28:51 +0800 Subject: [PATCH] ci: use reuse workflow for send email on fail Signed-off-by: Ray Huang --- .github/workflows/devbuild.yml | 38 ++++++--------------- .github/workflows/lint.yml | 36 +++++--------------- .github/workflows/nouse_install.yml | 34 +++++-------------- .github/workflows/send_email_on_fail.yml | 43 ++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 81 deletions(-) create mode 100644 .github/workflows/send_email_on_fail.yml diff --git a/.github/workflows/devbuild.yml b/.github/workflows/devbuild.yml index 9486b10b4..39c79391c 100644 --- a/.github/workflows/devbuild.yml +++ b/.github/workflows/devbuild.yml @@ -705,34 +705,16 @@ jobs: path: modmesh-pilot-win64/ send_email_on_failure: - name: send_emails_when_fails needs: [standalone_buffer, build_ubuntu, build_macos, build_windows] - runs-on: ubuntu-latest # Run if any of the dependencies failed in master branch if: ${{ always() && contains(needs.*.result, 'failure') && github.ref_name == 'master' && github.event.repository.fork == false }} - steps: - - name: Get current date and set to env - run: | - echo "DATE=$(date +%m/%d)" >> $GITHUB_ENV - - name: Send mail to mailing list - uses: dawidd6/action-send-mail@v6 - with: - server_address: smtp.gmail.com - server_port: 465 - username: ${{ secrets.EMAIL_USERNAME }} - password: ${{ secrets.EMAIL_PASSWORD }} - # Subject: Uses the Repository name - subject: ${{ env.DATE }} CI Failure in ${{ github.repository }} ${{ github.workflow }} workflow - # Body: Lists the result of every job - body: | - The workflow ${{ github.workflow }} has failed. - Job Status Report: - ------------------ - - standalone_buffer: ${{ needs.standalone_buffer.result }} - - build_ubuntu: ${{ needs.build_ubuntu.result }} - - build_macos: ${{ needs.build_macos.result }} - - build_windows: ${{ needs.build_windows.result }} - - Check the details at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - to: solvcon@googlegroups.com - from: solvcon_notification + uses: ./.github/workflows/send_email_on_fail.yml + with: + job_results: | + - standalone_buffer: ${{ needs.standalone_buffer.result }} + - build_ubuntu: ${{ needs.build_ubuntu.result }} + - build_macos: ${{ needs.build_macos.result }} + - build_windows: ${{ needs.build_windows.result }} + secrets: + EMAIL_USERNAME: ${{ secrets.EMAIL_USERNAME }} + EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 276bdb56c..616bc9e1c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -379,33 +379,15 @@ jobs: CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3)" send_email_on_failure: - name: send_emails_when_fails needs: [clang_format_check, tidy_flake8_ubuntu, tidy_flake8_macos] - runs-on: ubuntu-latest # Run if any of the dependencies failed in master branch if: ${{ always() && contains(needs.*.result, 'failure') && github.ref_name == 'master' && github.event.repository.fork == false }} - steps: - - name: Get current date and set to env - run: | - echo "DATE=$(date +%m/%d)" >> $GITHUB_ENV - - name: Send mail to mailing list - uses: dawidd6/action-send-mail@v6 - with: - server_address: smtp.gmail.com - server_port: 465 - username: ${{ secrets.EMAIL_USERNAME }} - password: ${{ secrets.EMAIL_PASSWORD }} - # Subject: Uses the Repository name - subject: ${{ env.DATE }} CI Failure in ${{ github.repository }} ${{ github.workflow }} workflow - # Body: Lists the result of every job - body: | - The workflow ${{ github.workflow }} has failed. - Job Status Report: - ------------------ - - clang_format_check: ${{ needs.clang_format_check.result }} - - tidy_flake8_ubuntu: ${{ needs.tidy_flake8_ubuntu.result }} - - tidy_flake8_macos: ${{ needs.tidy_flake8_macos.result }} - - Check the details at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - to: solvcon@googlegroups.com - from: solvcon_notification + uses: ./.github/workflows/send_email_on_fail.yml + with: + job_results: | + - clang_format_check: ${{ needs.clang_format_check.result }} + - tidy_flake8_ubuntu: ${{ needs.tidy_flake8_ubuntu.result }} + - tidy_flake8_macos: ${{ needs.tidy_flake8_macos.result }} + secrets: + EMAIL_USERNAME: ${{ secrets.EMAIL_USERNAME }} + EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }} diff --git a/.github/workflows/nouse_install.yml b/.github/workflows/nouse_install.yml index 72ca6bbc9..d0745e1c4 100644 --- a/.github/workflows/nouse_install.yml +++ b/.github/workflows/nouse_install.yml @@ -228,32 +228,14 @@ jobs: cd .. send_email_on_failure: - name: send_emails_when_fails needs: [nouse_install_ubuntu, nouse_install_macos] - runs-on: ubuntu-latest # Run if any of the dependencies failed in master branch if: ${{ always() && contains(needs.*.result, 'failure') && github.ref_name == 'master' && github.event.repository.fork == false }} - steps: - - name: Get current date and set to env - run: | - echo "DATE=$(date +%m/%d)" >> $GITHUB_ENV - - name: Send mail to mailing list - uses: dawidd6/action-send-mail@v6 - with: - server_address: smtp.gmail.com - server_port: 465 - username: ${{ secrets.EMAIL_USERNAME }} - password: ${{ secrets.EMAIL_PASSWORD }} - # Subject: Uses the Repository name - subject: ${{ env.DATE }} CI Failure in ${{ github.repository }} ${{ github.workflow }} workflow - # Body: Lists the result of every job - body: | - The workflow ${{ github.workflow }} has failed. - Job Status Report: - ------------------ - - nouse_install_ubuntu: ${{ needs.nouse_install_ubuntu.result }} - - nouse_install_macos: ${{ needs.nouse_install_macos.result }} - - Check the details at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} - to: solvcon@googlegroups.com - from: solvcon_notification + uses: ./.github/workflows/send_email_on_fail.yml + with: + job_results: | + - nouse_install_ubuntu: ${{ needs.nouse_install_ubuntu.result }} + - nouse_install_macos: ${{ needs.nouse_install_macos.result }} + secrets: + EMAIL_USERNAME: ${{ secrets.EMAIL_USERNAME }} + EMAIL_PASSWORD: ${{ secrets.EMAIL_PASSWORD }} diff --git a/.github/workflows/send_email_on_fail.yml b/.github/workflows/send_email_on_fail.yml new file mode 100644 index 000000000..7981a5e4c --- /dev/null +++ b/.github/workflows/send_email_on_fail.yml @@ -0,0 +1,43 @@ +name: Send Email on Failure + +on: + workflow_call: + inputs: + job_results: + description: 'String of job results' + required: true + type: string + secrets: + EMAIL_USERNAME: + required: true + EMAIL_PASSWORD: + required: true + +jobs: + send_email_on_failure: + name: send_emails_when_fails + runs-on: ubuntu-latest + steps: + - name: Get current date and set to env + run: | + echo "DATE=$(date +%m/%d)" >> $GITHUB_ENV + + - name: Send mail to mailing list + uses: dawidd6/action-send-mail@v6 + with: + server_address: smtp.gmail.com + server_port: 465 + username: ${{ secrets.EMAIL_USERNAME }} + password: ${{ secrets.EMAIL_PASSWORD }} + # Subject: Uses the Repository name + subject: ${{ env.DATE }} CI Failure in ${{ github.repository }} ${{ github.workflow }} workflow + # Body: Lists the result of every job + body: | + The workflow ${{ github.workflow }} has failed. + Job Status Report: + ------------------ + ${{ inputs.job_results }} + + Check the details at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + to: solvcon@googlegroups.com + from: solvcon_notification