revise adr to support user-name and user-email

This commit is contained in:
eric sciple 2020-02-14 14:05:48 -05:00
parent f858c22e96
commit 7c56228b5b

View file

@ -46,12 +46,17 @@ We want to take this opportunity to make behavioral changes, from v1. This docum
lfs: lfs:
description: 'Whether to download Git-LFS files' description: 'Whether to download Git-LFS files'
default: false 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: Note:
- `persist-credentials` is new - `persist-credentials` is new
- `path` behavior is different (refer [below](#path) for details) - `path` behavior is different (refer [below](#path) for details)
- `submodules` was removed (error if specified; add later if needed) - `submodules` was removed (error if specified; add later if needed)
- `user-name` and `user-email` are new
### Fallback to GitHub API ### Fallback to GitHub API
@ -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` Users may opt-out by specifying `persist-credentials: false`
Note: 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` - 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. - Additional public remotes also just work.
- If users want to authenticate to an additional private remote, they should provide the `token` input. - If users want to authenticate to an additional private remote, they should provide the `token` input.
@ -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. 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
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: github-actions-bot@users.noreply.github.com
- 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 ### Port to typescript
The checkout action should be a typescript action on the GitHub graph, for the following reasons: The checkout action should be a typescript action on the GitHub graph, for the following reasons: