Skip to content

feat: add default_author #181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Apr 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ Add a step like this to your workflow:
add: 'src'

# The name of the user that will be displayed as the author of the commit
# Default: author of the commit that triggered the run
# Default: depends on the default_author input
author_name: Your Name

# The email of the user that will be displayed as the author of the commit
# Default: author of the commit that triggered the run
# Default: depends on the default_author input
author_email: [email protected]

# Name of the branch to use, if different from the one that triggered the workflow
Expand All @@ -35,6 +35,13 @@ Add a step like this to your workflow:
# Default: '.'
cwd: './path/to/the/repo'

# Determines the way the action fills missing author name and email. Three options are available:
# - github_actor -> UserName <[email protected]>
# - user_info -> Your Display Name <[email protected]>
# - github_actions -> github-actions <email associated with the github logo>
# Default:
default_author: github_actor

# The message for the commit
# Default: 'Commit from GitHub Actions (name of the workflow)'
message: 'Your commit message'
Expand Down Expand Up @@ -97,6 +104,8 @@ You can use the `tag` option to enter the arguments for a `git add` command. In
When pushing, the action uses the token that the local git repository has been configured with: that means that if you want to change it you'll need to do it in the steps that run before this action. For example: if you set up your repo with [`actions/checkout`](https://github.com/actions/checkout/) then you have to add the token there.
Changing the token with which the repo is configured can be useful if you want to run CI checks on the commit pushed by this action; anyway, it has to be set up outside of this action.

The action automatically gets the GitHub token from a `github_token` input: this input should not be modified by the user, since it doesn't affect the commits as it's only used to access the GitHub API to get user info, in case they selected that option for the commit author.

### About `actions/checkout`

The token you use when setting up the repo with this action will determine what token `add-and-commit` will use.
Expand All @@ -120,7 +129,9 @@ For more info on how to use outputs, see ["Context and expression syntax"](https

### Examples:

If you don't want to use your GitHub username for the CI commits, you can [also use the user provided by GitHub for this task](https://github.com/actions/checkout/#push-a-commit-using-the-built-in-token):
If you don't want to use your GitHub username for the CI commits, you can use the `default_author` option to make it appear as if it was made by "github-actions"

<img src="https://user-images.githubusercontent.com/26386270/115738624-80b51780-a38d-11eb-9bbe-77461654274c.png" height=40/>

```yaml
on: push
Expand All @@ -130,11 +141,9 @@ jobs:
steps:
- uses: EndBug/[email protected]
with:
author_name: github-actions
author_email: 41898282+github-actions[bot]@users.noreply.github.com
default_author: github_actions
```

`41898282+github-actions[bot]@users.noreply.github.com` is the mail of the original GitHub Actions bot. If you use that, [the GitHub avatar is shown for the commits](https://github.community/t/github-actions-bot-email-address/17204).

Do you want to lint your JavaScript files, located in the `src` folder, with ESLint, so that fixable changes are done without your intervention? You can use a workflow like this:

Expand Down
12 changes: 10 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@ inputs:
author_name:
description: The name of the user that will be displayed as the author of the commit
required: false
default: ${{ github.actor }}
author_email:
description: The email of the user that will be displayed as the author of the commit
required: false
default: ${{ github.actor }}@users.noreply.github.com
branch:
description: Name of the branch to use, if different from the one that triggered the workflow
required: false
cwd:
description: The directory where your repository is located. You should use actions/checkout first to set it up
required: false
default: '.'
default_author:
description: How the action should fill missing author name or email.
required: false
default: 'github_actor'
message:
description: The message for the commit
required: false
Expand All @@ -41,6 +43,12 @@ inputs:
tag:
description: Arguments for the git tag command (the tag name always needs to be the first word not preceded by a hyphen)
required: false

# Input not required from the user
github_token:
description: The token used to make requests to the GitHub API. It's NOT used to make commits and should not be changed.
required: false
default: ${{ github.token }}

outputs:
committed:
Expand Down
2 changes: 1 addition & 1 deletion lib/index.js

Large diffs are not rendered by default.

Loading