Skip to content

Commit 76351d5

Browse files
authored
feat: Add commitMessage option (#75)
* feat: Add commitMessage option * docs: Add custom commit message option Close #74 cf. #72 and #73
1 parent fd02997 commit 76351d5

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ Do you want to skip the docker build step? OK, the script mode is available.
7272
- [⭐️ Deploy to external repository](#%EF%B8%8F-deploy-to-external-repository)
7373
- [⭐️ Force orphan](#%EF%B8%8F-force-orphan)
7474
- [⭐️ Set Git username and email](#%EF%B8%8F-set-git-username-and-email)
75+
- [⭐️ Set custom commit message](#%EF%B8%8F-set-custom-commit-message)
7576
- [⭐️ Script mode](#%EF%B8%8F-script-mode)
7677
- [Tips and FAQ](#tips-and-faq)
7778
- [⭐️ 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.
329330
useremail: "iris@peaceiris.com"
330331
```
331332

333+
### ⭐️ Set custom commit message
334+
335+
Set custom commit message.
336+
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}`.
337+
338+
```yaml
339+
- name: Deploy
340+
uses: peaceiris/actions-gh-pages@v2
341+
env:
342+
ACTIONS_DEPLOY_KEY: ${{ secrets.ACTIONS_DEPLOY_KEY }}
343+
PUBLISH_BRANCH: gh-pages
344+
PUBLISH_DIR: ./public
345+
with:
346+
commitMessage: ${{ github.event.commits[0].message }}
347+
```
348+
332349
### ⭐️ Script mode
333350

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

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,6 @@ inputs:
2626
useremail:
2727
description: 'Set Git user.email'
2828
required: false
29+
commitMessage:
30+
description: 'Set custom commit message'
31+
required: false

entrypoint.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,16 @@ git add --all
118118

119119
print_info "Allowing empty commits: ${INPUT_EMPTYCOMMITS}"
120120

121+
if [ -n "${INPUT_COMMITMESSAGE}" ]; then
122+
BASE_COMMIT_MESSAGE="${INPUT_COMMITMESSAGE}"
123+
else
124+
BASE_COMMIT_MESSAGE="Automated deployment: $(date -u)"
125+
fi
126+
121127
if [ -n "${EXTERNAL_REPOSITORY}" ]; then
122-
COMMIT_MESSAGE="Automated deployment: $(date -u) ${GITHUB_REPOSITORY}@${GITHUB_SHA}"
128+
COMMIT_MESSAGE="${BASE_COMMIT_MESSAGE} ${GITHUB_REPOSITORY}@${GITHUB_SHA}"
123129
else
124-
COMMIT_MESSAGE="Automated deployment: $(date -u) ${GITHUB_SHA}"
130+
COMMIT_MESSAGE="${BASE_COMMIT_MESSAGE} ${GITHUB_SHA}"
125131
fi
126132

127133
if [[ ${INPUT_EMPTYCOMMITS} == "false" ]]; then

0 commit comments

Comments
 (0)