feat: Add INPUT_FORCEORPHAN, close #42

This commit is contained in:
peaceiris 2019-10-17 07:41:16 +09:00
parent 7f7794a793
commit 7216888f95
2 changed files with 11 additions and 1 deletions

View File

@ -16,3 +16,7 @@ inputs:
description: 'If existing files in the publish branch should be not removed before deploying'
required: false
default: 'false'
forceOrphan:
description: 'Keep only the latest commit on a GitHub Pages branch'
required: false
default: 'false'

View File

@ -77,7 +77,13 @@ fi
remote_branch="${PUBLISH_BRANCH}"
local_dir="${HOME}/ghpages_${RANDOM}"
if git clone --depth=1 --single-branch --branch "${remote_branch}" "${remote_repo}" "${local_dir}"; then
if [ -n "${INPUT_FORCEORPHAN}" ]; then
print_info "force ophan: ${INPUT_FORCEORPHAN}"
cd "${PUBLISH_DIR}"
git init
git checkout --orphan "${remote_branch}"
elif git clone --depth=1 --single-branch --branch "${remote_branch}" "${remote_repo}" "${local_dir}"; then
cd "${local_dir}"
if [[ ${INPUT_KEEPFILES} == "true" ]]; then