Getting the commit author details for a GitHub App account

When using GitHub Apps, you may want to commit files to repos, and have the right commit metadata set up so the author shows correctly.

Getting this email address is unfortunately a little awkward, and doesn't seem to be made super visible in the GitHub UI or docs, so I thought I'd blogument it.

For instance, let's say that we want to find the email for Renovate GitHub app and write a commit like (example commit), which has the commit header:

commit c5a5c891104b82c0862b5d009c697be4a4716602 (tag: 35.31.1)
Author: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Date:   Sat Apr 1 12:11:23 2023 +0200

    build(deps): update dependency @renovatebot/osv-offline to v1.2.4 (#21277)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

 package.json |  2 +-
 yarn.lock    | 11 ++++++-----
 2 files changed, 7 insertions(+), 6 deletions(-)

The ID here that is key is that we want to take the user ID of the bot account that's created for the app, which can be found on the lookup of the user, allowing us to write the following script:

app_name=renovate
username="${app_name}[bot]"
app_id="$(gh api "/users/$username" --jq '.id')"

echo "Author: $username <${app_id}+${username}@users.noreply.github.com>"

Written by Jamie Tanna's profile image Jamie Tanna on , and last updated on .

Content for this article is shared under the terms of the Creative Commons Attribution Non Commercial Share Alike 4.0 International, and code is shared under the Apache License 2.0.

#blogumentation #github.

This post was filed under articles.

Interactions with this post

Interactions with this post

Below you can find the interactions that this page has had using WebMention.

Have you written a response to this post? Let me know the URL:

Do you not have a website set up with WebMention capabilities? You can use Comment Parade.