Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
feat: Add username and useremail options (#67)
* feat: Add username and useremail options
* docs: Add Git username and email section

Close #66
  • Loading branch information
Shohei Ueda authored and GitHub committed Dec 24, 2019
1 parent bdedb4e commit 0252bbe
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
18 changes: 18 additions & 0 deletions README.md
Expand Up @@ -71,6 +71,7 @@ Do you want to skip the docker build step? OK, the script mode is available.
- [⭐️ Keeping existing files](#%EF%B8%8F-keeping-existing-files)
- [⭐️ Deploy to external repository](#%EF%B8%8F-deploy-to-external-repository)
- [⭐️ Force orphan](#%EF%B8%8F-force-orphan)
- [⭐️ Set Git username and email](#%EF%B8%8F-set-git-username-and-email)
- [⭐️ Script mode](#%EF%B8%8F-script-mode)
- [Tips and FAQ](#tips-and-faq)
- [⭐️ Use the latest and specific release](#%EF%B8%8F-use-the-latest-and-specific-release)
Expand Down Expand Up @@ -311,6 +312,23 @@ This allows you to make your publish branch with only the latest commit.
forceOrphan: true
```

### ⭐️ Set Git username and email

Set custom `git config user.name` and `git config user.email`.
A commit is always created with the same user.

```yaml
- name: Deploy
uses: peaceiris/actions-gh-pages@v2
env:
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
PUBLISH_BRANCH: gh-pages
PUBLISH_DIR: ./public
with:
username: "iris"
useremail: "iris@peaceiris.com"
```

### ⭐️ Script mode

From `v2.5.0`, we can run this action as a shell script.
Expand Down
6 changes: 6 additions & 0 deletions action.yml
Expand Up @@ -20,3 +20,9 @@ inputs:
description: 'Keep only the latest commit on a GitHub Pages branch'
required: false
default: 'false'
username:
description: 'Set Git user.name'
required: false
useremail:
description: 'Set Git user.email'
required: false
12 changes: 10 additions & 2 deletions entrypoint.sh
Expand Up @@ -102,8 +102,16 @@ else
fi

# push to publishing branch
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
if [[ -n "${INPUT_USERNAME}" ]]; then
git config user.name "${INPUT_USERNAME}"
else
git config user.name "${GITHUB_ACTOR}"
fi
if [[ -n "${INPUT_USEREMAIL}" ]]; then
git config user.email "${INPUT_USEREMAIL}"
else
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
fi
git remote rm origin || true
git remote add origin "${remote_repo}"
git add --all
Expand Down

0 comments on commit 0252bbe

Please sign in to comment.