When using the GitHub Api you can supply the author and committer information, such as when you PUT
a content
file.
I want to be able to use the GitHub App as the committer
so that people understand the commit was done using the third-party tool and the author information is kept as the authenticated user.
Currently I am using the app name as the name
of the committer
and an email for the apps' domain. But that does not tie the commit to the app at all (ex: I would have to create a bot account with that email to get it show any kind of profile, etc but that would not really be tied to my Github App).
What is the correct way to do this? Or should I not be trying to use the App as the committer
and just use the authenticated user as the committer
?
You could use the same content api you mentioned, to figure out what you need. The response you get by creating a file is a json that will tell you the user-id that was assigned to your github app. Pay attention to the author
object under commit
, you should see something like this:
curl \
-X PUT \
-H "Authorization: token ${TOKEN}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/msgongora/fubectl/contents/test-file \
-d '{"message":"message","content":"Y29udGVudA==","branch":"mrsg"}'
{
"content": {
...
"commit": {
...
"author": {
"name": "myciapp[bot]",
"email": "1234545665+myciapp[bot]@users.noreply.github.com",
"date": "2021-04-07T06:28:18Z"
},
...
}
Once you have that, you can set the name and email for your app as if you were setting it for a regular user:
git config --global user.name "myciapp[bot]"
git config --global user.email 1234545665+myciapp[bot]@users.noreply.github.com