Skip to content

Commit 0252bbe

Browse files
authored
feat: Add username and useremail options (#67)
* feat: Add username and useremail options * docs: Add Git username and email section Close #66
1 parent bdedb4e commit 0252bbe

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ Do you want to skip the docker build step? OK, the script mode is available.
7171
- [⭐️ Keeping existing files](#%EF%B8%8F-keeping-existing-files)
7272
- [⭐️ Deploy to external repository](#%EF%B8%8F-deploy-to-external-repository)
7373
- [⭐️ Force orphan](#%EF%B8%8F-force-orphan)
74+
- [⭐️ Set Git username and email](#%EF%B8%8F-set-git-username-and-email)
7475
- [⭐️ Script mode](#%EF%B8%8F-script-mode)
7576
- [Tips and FAQ](#tips-and-faq)
7677
- [⭐️ Use the latest and specific release](#%EF%B8%8F-use-the-latest-and-specific-release)
@@ -311,6 +312,23 @@ This allows you to make your publish branch with only the latest commit.
311312
forceOrphan: true
312313
```
313314

315+
### ⭐️ Set Git username and email
316+
317+
Set custom `git config user.name` and `git config user.email`.
318+
A commit is always created with the same user.
319+
320+
```yaml
321+
- name: Deploy
322+
uses: peaceiris/actions-gh-pages@v2
323+
env:
324+
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
325+
PUBLISH_BRANCH: gh-pages
326+
PUBLISH_DIR: ./public
327+
with:
328+
username: "iris"
329+
useremail: "[email protected]"
330+
```
331+
314332
### ⭐️ Script mode
315333

316334
From `v2.5.0`, we can run this action as a shell script.

action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,9 @@ inputs:
2020
description: 'Keep only the latest commit on a GitHub Pages branch'
2121
required: false
2222
default: 'false'
23+
username:
24+
description: 'Set Git user.name'
25+
required: false
26+
useremail:
27+
description: 'Set Git user.email'
28+
required: false

entrypoint.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,16 @@ else
102102
fi
103103

104104
# push to publishing branch
105-
git config user.name "${GITHUB_ACTOR}"
106-
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
105+
if [[ -n "${INPUT_USERNAME}" ]]; then
106+
git config user.name "${INPUT_USERNAME}"
107+
else
108+
git config user.name "${GITHUB_ACTOR}"
109+
fi
110+
if [[ -n "${INPUT_USEREMAIL}" ]]; then
111+
git config user.email "${INPUT_USEREMAIL}"
112+
else
113+
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
114+
fi
107115
git remote rm origin || true
108116
git remote add origin "${remote_repo}"
109117
git add --all

0 commit comments

Comments
 (0)