Skip to content
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

revise adr to support user-name and user-email #158

Closed
wants to merge 1 commit into from
Closed
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
33 changes: 32 additions & 1 deletion adrs/0153-checkout-v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,17 @@ We want to take this opportunity to make behavioral changes, from v1. This docum
lfs:
description: 'Whether to download Git-LFS files'
default: false
user-name:
description: 'User name to set in the local git config'
user-email:
description: 'User email to set in the local git config'
```

Note:
- `persist-credentials` is new
- `path` behavior is different (refer [below](#path) for details)
- `submodules` was removed (error if specified; add later if needed)
- `user-name` and `user-email` are new

### Fallback to GitHub API

Expand All @@ -70,7 +75,6 @@ A post script will remove the credentials from the git config (cleanup for self-
Users may opt-out by specifying `persist-credentials: false`

Note:
- Users scripting `git commit` may need to set the username and email. The service does not provide any reasonable default value. Users can add `git config user.name <NAME>` and `git config user.email <EMAIL>`. We will document this guidance.
- The auth header (stored in the repo's git config), is scoped to all of github `http.https://github.com/.extraheader`
- Additional public remotes also just work.
- If users want to authenticate to an additional private remote, they should provide the `token` input.
Expand Down Expand Up @@ -179,6 +183,33 @@ A better solution is:

Given a source file path, walk up the directories until the first `.git/config` is found. Check if it matches the self repo (`url = https://github.com/OWNER/REPO`). If not, drop the source file path.


### User name and email
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unclear how this will be impacted by submodules support. probably need to add to local git config for each submodule too


The `user-name` and `user-email` can be used to set the user name and email in the local git config.

This is useful for the command `git commit`, which requires a user name and email to be configured.

The example uses the GITHUB_TOKEN to push a commit to the server:

```yaml
jobs:
my-job:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
user-name: github-actions
user-email: [email protected]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am unsure off the top of my head, but is there a way in your actions file to reference the user and email on the commit being built from or the action triggering user? As I mentioned in #13 I would like to be able to amend the commit or make a new one without having different commit ownership.

If not it would be awesome if these were just defaulted to that with these option here to override. Or is there a reason that is not a good idea?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On push it looks like ${{ github.event.head_commit.author.name }} and ${{ github.event.head_commit.author.email }} can be used.

Haven't looked at values on pull_request. I dumped the context using this:

on: push
jobs:
  build:
    runs-on: [ubuntu-latest]
    steps:
      - run: |
          echo "$GITHUB_CONTEXT"
        env:
          GITHUB_CONTEXT: ${{ toJson(github) }}

I'm hesitant to add any default since it would regress folks who are setting and relying on global config user name. If we make a new major version (v3), then would be an opportunity to break compat.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, as long as there is an easy way to achieve this!

Copy link

@eine eine Feb 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wesleytodd I believe you can read the context/json and set outputs in the step before using checkout. However, this seems unnecessarily complex. @ericsciple, what do you think about supporting a single user field that expects either username <useremail> or auto? Naturally, auto would imply the behaviour expected by @wesleytodd (and me).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does GitHub associate [email protected] with github-actions[bot]? Otherwise, github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> might be a better default as I mentioned in #13.

@wesleytodd Amending a commit does not change the author unless --reset-author or --author=<author> is set. Only the commiter is changed but I think that is fine in most cases since it reflects what is actually happening.

- run: |
if [ ! -e generated.txt ]; then
echo hello > generated.txt
git add generated.txt
git commit -m "generated file"
git push
fi
```

### Port to typescript

The checkout action should be a typescript action on the GitHub graph, for the following reasons:
Expand Down