From 76351d52b898c8c26089ac1980da3418927a77b7 Mon Sep 17 00:00:00 2001 From: Shohei Ueda <30958501+peaceiris@users.noreply.github.com> Date: Mon, 6 Jan 2020 23:46:48 +0900 Subject: [PATCH] feat: Add commitMessage option (#75) * feat: Add commitMessage option * docs: Add custom commit message option Close #74 cf. #72 and #73 --- README.md | 17 +++++++++++++++++ action.yml | 3 +++ entrypoint.sh | 10 ++++++++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1108ba0..d3fb9fa 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,7 @@ Do you want to skip the docker build step? OK, the script mode is available. - [⭐️ 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) + - [⭐️ Set custom commit message](#%EF%B8%8F-set-custom-commit-message) - [⭐️ 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) @@ -329,6 +330,22 @@ A commit is always created with the same user. useremail: "iris@peaceiris.com" ``` +### ⭐️ Set custom commit message + +Set custom commit message. +When we create a commit with a message `docs: Update some post`, a deployment commit will be generated with a message `docs: Update some post ${GITHUB_SHA}`. + +```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: + commitMessage: ${{ github.event.commits[0].message }} +``` + ### ⭐️ Script mode From `v2.5.0`, we can run this action as a shell script. diff --git a/action.yml b/action.yml index 823ab78..b569493 100644 --- a/action.yml +++ b/action.yml @@ -26,3 +26,6 @@ inputs: useremail: description: 'Set Git user.email' required: false + commitMessage: + description: 'Set custom commit message' + required: false diff --git a/entrypoint.sh b/entrypoint.sh index af3ad95..4efb3ad 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -118,10 +118,16 @@ git add --all print_info "Allowing empty commits: ${INPUT_EMPTYCOMMITS}" +if [ -n "${INPUT_COMMITMESSAGE}" ]; then + BASE_COMMIT_MESSAGE="${INPUT_COMMITMESSAGE}" +else + BASE_COMMIT_MESSAGE="Automated deployment: $(date -u)" +fi + if [ -n "${EXTERNAL_REPOSITORY}" ]; then - COMMIT_MESSAGE="Automated deployment: $(date -u) ${GITHUB_REPOSITORY}@${GITHUB_SHA}" + COMMIT_MESSAGE="${BASE_COMMIT_MESSAGE} ${GITHUB_REPOSITORY}@${GITHUB_SHA}" else - COMMIT_MESSAGE="Automated deployment: $(date -u) ${GITHUB_SHA}" + COMMIT_MESSAGE="${BASE_COMMIT_MESSAGE} ${GITHUB_SHA}" fi if [[ ${INPUT_EMPTYCOMMITS} == "false" ]]; then