Skip to content

Commit

Permalink
Merge pull request #5 from tshion/feature/add_manual
Browse files Browse the repository at this point in the history
任意のGit ユーザーを設定できるように改良
  • Loading branch information
tshion authored May 4, 2024
2 parents 0e9c86a + 1fa19cb commit e6be4be
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/run-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,21 @@ jobs:
global: TRUE
user: LATEST-COMMIT
- run: bash .github/workflows/display.bash

case4:
strategy:
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest
runs-on: ${{ matrix.os }}
steps:
# https://github.com/actions/checkout
- uses: actions/checkout@v4
- uses: ./
with:
user: specific
email: hoge@example.com
name: hoge
- run: bash .github/workflows/display.bash
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Apply a well-known git user to `git config user.*`.
- uses: tshion/apply-git-user@(version)
with:
user: (git user)
email: (git user email) # Set if `user` is `specific`
name: (git user name) # Set if `user` is `specific`
```
Replace `(git user)` with one of the following values.
Expand All @@ -21,7 +23,8 @@ Replace `(git user)` with one of the following values.
--- | --- | ---
`actions-user` | ![actions-user](./docs/actions-user.png) | |
`github-actions` | ![github-actions](./docs/github-actions.png) | |
`latest-commit` | ![Latest git commit user](./docs/latest-commit.png) | Latest git commit user
`latest-commit` | e.g. ![latest commit](./docs/user.png) | Latest git commit user
`specific` | e.g. ![specific](./docs/user.png) | Set up a specific user by `email` and `name`.

### Use `working directory`
``` yaml
Expand Down
15 changes: 14 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@ branding:
color: orange

inputs:
email:
description: "If 'user' is 'specific', what to set for 'user.email'"
required: false
default: ""
global:
description: "Whether to set '--global' or not"
required: false
default: "false"
name:
description: "If 'user' is 'specific', what to set for 'user.name'"
required: false
default: ""
path:
description: "Relative path under $GITHUB_WORKSPACE to place the repository"
required: false
Expand All @@ -25,6 +33,8 @@ runs:
GLOBAL: ${{ inputs.global }}
PATH_DIR: ${{ inputs.path }}
USER: ${{ inputs.user }}
USER_EMAIL: ${{ inputs.email }}
USER_NAME: ${{ inputs.name }}
run: |
echo "path: $PATH_DIR"
cd $PATH_DIR
Expand All @@ -42,8 +52,11 @@ runs:
elif [ $user = 'latest-commit' ]; then
email="$(git --no-pager log --format=format:'%ae' -n 1)"
name="$(git --no-pager log --format=format:'%an' -n 1)"
elif [ $user = 'specific' ]; then
email="$USER_EMAIL"
name="$USER_NAME"
else
echo "::error::Please set 'user' to either 'actions-user', 'github-actions' or 'latest-commit'."
echo "::error::Please set 'user' to either 'actions-user', 'github-actions', 'latest-commit' or 'specific'."
exit 1
fi
echo "name: $name"
Expand Down
File renamed without changes

0 comments on commit e6be4be

Please sign in to comment.