Get Email address of the user running the github workflow

I am working on a workflow that takes some time to finish the execution. My workflow can be run by different users in a team. Since the workflow takes some amount of time to complete, what I want is to fetch the email address of the logged in user who triggered the workflow.
Once I have the email address, I can send an email to the use with the url of the workflow run.
I came across but this returned me the login name for the user logged in. What I really want is the email address of the logged in user.

Any pointers how to get the email address?


I’ve never done this but you could either use the context (the login of the user that initiated the workflow run) to retrieve their email address from the API or github.sha (the commit SHA that triggered the workflow run) to retrieve the email address attached with the commit.

For the latter, it would look something like the following (untested):

  email: ${{ steps.fetch-email.outputs.address }}
  - id: fetch-email
      COMMIT_EMAIL=$(git log --format='%ae' ${{ github.sha }}^!)
      echo "::set-output name=address::$COMMIT_EMAIL"