Logging into Git as a GitHub App

How would I log into Git as a GitHub App? :thinking: I’ve sort of got it working, but I’m curious what the “actual” way of doing this is :smiley: What would I set as the Git username and email? Thank you!

:wave: @cjdenio –– great questions! Thank you for raising them here :bowing_man:

How would I log into Git as a GitHub App? :thinking: I’ve sort of got it working, but I’m curious what the “actual” way of doing this is :smiley:

It’s possible to authenticate with GitHub.com as a GitHub App; here’s the section on HTTP-based Git access by an installation.

What would I set as the Git username and email? Thank you!

That’s a great question! The way we currently attribute commits made by GitHub Apps isn’t currently publicly documented in our Setting your commit email address article and is subject to change at anytime without notice. If it’s helpful in the meantime, here’s something you could try (though your mileage may vary over time :v:).

You could set the Git username is the name of your application with [bot] appended at the end. For example, if your bot’s name is machina, then the Git username is machina[bot]:

git config user.name "machina[bot]"

For the email, you could set it to the GitHub App’s user id, a plus sign (+), and its name with [bot] appended, followed by the Users No Reply GitHub email address. For example, if the app’s user id is 123456789, then the email would be:

git config user.email "123456789+machina[bot]@users.noreply.github.com"

Here’s an example commit showing the GitHub Actions installation committing to a repository: actions-packages-examples/github-script__playground@f75a13b

In its patch file, observe the second line’s contents:

From: "github-actions[bot]"
 <41898282+github-actions[bot]@users.noreply.github.com>

One approach for obtaining the GitHub App’s user ID is to create a new file using the Contents API, navigating to the commit on GitHub.com, and appending .patch to the end of that commit URL to reveal the patch information showcasing the actor name and email address we use. I hope this helps!

5 Likes

Wow, this is is awesome! :exploding_head: Thanks for taking the time to answer; I really appreciate having closure on this question :smiley:

4 Likes

@francisfuzz Is there a way to authenticate with Github over SSH as a Github App - maybe somehow using Github App private key?
And by over SSH I meant to be able to push and pull code, not any shell access (obviously).

Is there a way to authenticate with Github over SSH as a Github App - maybe somehow using Github App private key?
And by over SSH I meant to be able to push and pull code, not any shell access (obviously).

:wave: @inez: Great question! There’s no way for a GitHub App to authenticate using an SSH key at this time.