From 0252bbee4ddab91da948416bd5d300a7baf47216 Mon Sep 17 00:00:00 2001 From: Shohei Ueda <30958501+peaceiris@users.noreply.github.com> Date: Tue, 24 Dec 2019 15:22:01 +0900 Subject: [PATCH] feat: Add username and useremail options (#67) * feat: Add username and useremail options * docs: Add Git username and email section Close #66 --- README.md | 18 ++++++++++++++++++ action.yml | 6 ++++++ entrypoint.sh | 12 ++++++++++-- 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 543ad60..1108ba0 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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. diff --git a/action.yml b/action.yml index 9a64dd6..823ab78 100644 --- a/action.yml +++ b/action.yml @@ -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 diff --git a/entrypoint.sh b/entrypoint.sh index b4d9d59..663f9d4 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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