stefanzweifel / git-auto-commit-action

Automatically commit and push changed files back to GitHub with this GitHub Action for the 80% use case.
MIT License
1.98k stars 227 forks source link

Clarify default author/user/email in readme #123

Closed vincerubinetti closed 3 years ago

vincerubinetti commented 3 years ago

Some suggestions for the readme.

Currently, this is near the top:

The default committer is "GitHub Actions actions@github.com", and the default author of the commit is "Your GitHub Username github_username@users.noreply.github.com".

Seems kinda weird to put that at the top. I recommend putting that info in the Usage section, since that's where all the other defaults are specified. Also I think the explanation of the defaults could be better.

How about something like this:

    # Optional commit user and author settings
    commit_user_name: Jane Smith # defaults to username of commit that triggered the run
    commit_user_email: jane-smith@example.org # defaults to email of commit that triggered the run
    commit_author: Jane Smith <jane-smith@example.org> # defaults to author of commit that triggered the run

Also, it seems like that maybe that's not currently how the default author settings work, but I think that's how they should work, so maybe I'll create a feature request for that.

stefanzweifel commented 3 years ago

Thanks for the suggestions! Always love when people have ideas to improve the documentation.

Currently, this is near the top: […]

Yeah, that line seems out of place in the README. It's an artefact from the earliest days of the Action. I will update the README shortly.

I will update the README with some of your suggestions, but the name and email of the user of the commit is by default "GitHub Actions" and "actions@github.com". This is by design.

When I developed this Action, I wanted to to make it clear to the "consumer" that the Action has been created by a bot and not by an actual human. The README doesn't reflect this decision. I will try to add section which explains this more.

stefanzweifel commented 3 years ago

The README has been updated in https://github.com/stefanzweifel/git-auto-commit-action/commit/021e855056637cd1b5c7722fa8305c944945f93d and https://github.com/stefanzweifel/git-auto-commit-action/commit/7cec9acee664884964a44d29ae0a040333c45e12.

As mentioned, the current "feature" of setting different user and author stays for now. I will close this issue now.

If you think the README can be improved or other things might be unclear, please reopen this issue, leave a comment or create a new issue.

npanuhin commented 8 months ago

@stefanzweifel, can I ask a few questions regarding the commit author field:

the name and email of the user of the commit is by default "GitHub Actions" and "actions@github.com". This is by design.

When using the --amend commit option I noticed that git-auto-commit-action changes the author of the commit. For me, the change was as follows:

Q1) Did you actually intend to change the commit author field by default? If so, it would be nice to have an option to leave the commit author field untouched)

README states the following about the committed author filed:

commit_author: Author <actions@github.com> # defaults to author of the commit that triggered the run

Q2) This section only shows Author <actions@github.com> as an example and never states that the default commit author will be username <username@users.noreply.github.com>. I find this a bit misleading, maybe we should add an actual email address somewhere in the description?

Q3) Can you clarify, what is meant by "defaults to author of the commit that triggered the run"? Because many options fall under this description (untouched, changed to username@users.noreply.github.com, changed to username@github.com, etc.)

To sum up, if a change in the commit author field by default is intended, I suggest making roughly the following change to the README:

- commit_author: Author <actions@github.com> # defaults to author of the commit that triggered the run
+ commit_author: Author <actions@github.com> # defaults to "username <username@users.noreply.github.com>", where "username" belongs to the author of the commit that triggered the run
stefanzweifel commented 8 months ago

@npanuhin More than happy to answer your questions.

Q1) Did you actually intend to change the commit author field by default? If so, it would be nice to have an option to leave the commit author field untouched)

It wasn't my intention, but in your described scenario, --amend changes the author of the existing commit. --amend is a git feature and not necessarily a git-auto-commit-feature.

(There is a --reset-author option available for git which could help you here. (I've never used this before, just found it in the docs))

If you must use --amend and want to make 100% sure that the author remains the same, you would have to extract the author details in your workflow and pass the values to git-auto-commit.

Q2) This section only shows Author actions@github.com as an example and never states that the default commit author will be username username@users.noreply.github.com. I find this a bit misleading, maybe we should add an actual email address somewhere in the description?

More than happy to merge a pull request that improves the documentation around this and gives a good example.

The default commit_author value is declared in action.yml, but I agree that this is a bit too hidden.

Q3) Can you clarify, what is meant by "defaults to author of the commit that triggered the run"? Because many options fall under this description (untouched, changed to username@users.noreply.github.com, changed to username@github.com, etc.)

With "defaults to author of the commit that triggered the run" I tried to describe/explain, that the so called github.actor GitHub Actions context is used to build the commit_author values.

More information about the contexts are in the GitHub Actions docs: https://docs.github.com/en/actions/learn-github-actions/contexts

I'm more than happy to merge a PR with your proposed changes to the README.

npanuhin commented 8 months ago

Thank you very much for your quick response! I forgot to look into the code before asking a question — action.yaml does explain everything)

I will extract the committed author and add it as a parameter for git-auto-commit-action in my workflow, thanks for the tip!

I opened a PR with the previously proposed change + your tip in the example section: #315