Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
08937a7751 | ||
|
|
fd02997068 | ||
|
|
127155c640 | ||
|
|
0252bbee4d | ||
|
|
bdedb4ed2b |
@@ -1,4 +1,4 @@
|
|||||||
FROM alpine:3.10.3
|
FROM alpine:3.11.2
|
||||||
|
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache \
|
||||||
bash \
|
bash \
|
||||||
|
|||||||
18
README.md
18
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)
|
- [⭐️ Keeping existing files](#%EF%B8%8F-keeping-existing-files)
|
||||||
- [⭐️ Deploy to external repository](#%EF%B8%8F-deploy-to-external-repository)
|
- [⭐️ Deploy to external repository](#%EF%B8%8F-deploy-to-external-repository)
|
||||||
- [⭐️ Force orphan](#%EF%B8%8F-force-orphan)
|
- [⭐️ 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)
|
- [⭐️ Script mode](#%EF%B8%8F-script-mode)
|
||||||
- [Tips and FAQ](#tips-and-faq)
|
- [Tips and FAQ](#tips-and-faq)
|
||||||
- [⭐️ Use the latest and specific release](#%EF%B8%8F-use-the-latest-and-specific-release)
|
- [⭐️ 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
|
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
|
### ⭐️ Script mode
|
||||||
|
|
||||||
From `v2.5.0`, we can run this action as a shell script.
|
From `v2.5.0`, we can run this action as a shell script.
|
||||||
|
|||||||
@@ -20,3 +20,12 @@ inputs:
|
|||||||
description: 'Keep only the latest commit on a GitHub Pages branch'
|
description: 'Keep only the latest commit on a GitHub Pages branch'
|
||||||
required: false
|
required: false
|
||||||
default: 'false'
|
default: 'false'
|
||||||
|
username:
|
||||||
|
description: 'Set Git user.name'
|
||||||
|
required: false
|
||||||
|
useremail:
|
||||||
|
description: 'Set Git user.email'
|
||||||
|
required: false
|
||||||
|
commitMessage:
|
||||||
|
description: 'Set custom commit message'
|
||||||
|
required: false
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ elif git clone --depth=1 --single-branch --branch "${remote_branch}" "${remote_r
|
|||||||
git rm -r --ignore-unmatch '*'
|
git rm -r --ignore-unmatch '*'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
find "${GITHUB_WORKSPACE}/${PUBLISH_DIR}" -maxdepth 1 | \
|
find "${GITHUB_WORKSPACE}/${PUBLISH_DIR}" -maxdepth 1 -not -name ".git" -not -name ".github" | \
|
||||||
tail -n +2 | \
|
tail -n +2 | \
|
||||||
xargs -I % cp -rf % "${local_dir}/"
|
xargs -I % cp -rf % "${local_dir}/"
|
||||||
else
|
else
|
||||||
@@ -102,14 +102,34 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# push to publishing branch
|
# push to publishing branch
|
||||||
git config user.name "${GITHUB_ACTOR}"
|
if [[ -n "${INPUT_USERNAME}" ]]; then
|
||||||
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
|
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 rm origin || true
|
||||||
git remote add origin "${remote_repo}"
|
git remote add origin "${remote_repo}"
|
||||||
git add --all
|
git add --all
|
||||||
|
|
||||||
print_info "Allowing empty commits: ${INPUT_EMPTYCOMMITS}"
|
print_info "Allowing empty commits: ${INPUT_EMPTYCOMMITS}"
|
||||||
COMMIT_MESSAGE="Automated deployment: $(date -u) ${GITHUB_SHA}"
|
|
||||||
|
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="${BASE_COMMIT_MESSAGE} ${GITHUB_REPOSITORY}@${GITHUB_SHA}"
|
||||||
|
else
|
||||||
|
COMMIT_MESSAGE="${BASE_COMMIT_MESSAGE} ${GITHUB_SHA}"
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ ${INPUT_EMPTYCOMMITS} == "false" ]]; then
|
if [[ ${INPUT_EMPTYCOMMITS} == "false" ]]; then
|
||||||
git commit -m "${COMMIT_MESSAGE}" || skip
|
git commit -m "${COMMIT_MESSAGE}" || skip
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user