'Github actions - How to send or attach the build failed logs through E-Mail?

I have a Github build workflow. In that, the steps will continue when the previous steps are failed or succeed. In the end, I am sending an email to the developer about the build status. This is working perfectly.

The requirement is >>>>>> I need to notify the developers with the logs of the build (Particularly when the build failed).

Example Below image: If the build step failed I need to send these lines 4 & 5 like a log file or text output or something.

enter image description here

I have checked any build context variable available. But I didn't find any. How I can achieve this? Is there any way to do this?

Workflow.yml:

on: push

name: E-mail Notification

jobs:
  build:
    runs-on: ubuntu-latest
    name: Notify email
    steps:
    - name: Hello World
      id: response
      run: echo Hello, world! && exit 1 - make build failing

    - name: Hello World1
      id: response1
      run: echo Hello, world!

    - name: Send mail
      if: always()
      uses: dawidd6/action-send-mail@v3
      with:
        # mail server settings
        server_address: smtp.gmail.com
        server_port: 465
        # Optional (recommended): mail server username:
        username: ${{secrets.MAIL_USERNAME}}
        # Optional (recommended) mail server password:
        password: ${{secrets.MAIL_PASSWORD}}
        # email subject
        subject: ${{ github.repository }} ${{ github.job }} is ${{ job.status }}
        # email body as text
        body: ${{ github.job }} job in workflow ${{ github.workflow }} of ${{ github.repository }} 
        is ${{ job.status }}.
        # comma-separated string, send email to
        to: [email protected]
        # from email name
        from: Admin


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source