How can I get the e-mail address of the committer?

So I have a workflow in which a push (by the merge of a PR or a simple push) would trigger a bot to push to another repo with the user’s name and details, that triggered the action. I managed to get the name by {{ github.event.inputs.name }}. But what about the user’s e-mail?

For the push event, there is: ${{github.event.pusher.email}}.

See: https://developer.github.com/webhooks/event-payloads/#push

2 Likes

@ohsayan,

If the workflow is triggered by push event, you can use the following properties to get the email and name of the pusher from the github context of the workflow run.

github.event.pusher.email
github.event.pusher.name

For example:

on: push

jobs:
  job1:
    runs-on: ubuntu-latest
    steps:
      - name: View the information of the pusher
        run: |
          echo "The name of the pusher: ${{ github.event.pusher.name }}"
          echo "The email of the pusher: ${{ github.event.pusher.email }}"

      - name: View the github context
        run: echo "$GITHUB_CONTEXT"
        env:
          GITHUB_CONTEXT: ${{ toJson(github) }}
2 Likes

@dawidd6’s link points to the legacy documentation, the new link is:
https://docs.github.com/en/free-pro-team@latest/developers/webhooks-and-events/webhook-events-and-payloads#push

1 Like