Compare commits

...

5 Commits

Author SHA1 Message Date
peaceiris
b6a9b4b75a Merge branch 'master' into force-orphan 2019-10-17 16:38:24 +09:00
peaceiris
a0131c39a3 enhance: forceOrphan condition check 2019-10-17 08:53:02 +09:00
peaceiris
a899cb542b fix: Force push when forceOrphan is true 2019-10-17 07:51:48 +09:00
peaceiris
f83fbff9f3 fix: forceOrphan condition check 2019-10-17 07:46:50 +09:00
peaceiris
7216888f95 feat: Add INPUT_FORCEORPHAN, close #42 2019-10-17 07:41:16 +09:00
2 changed files with 17 additions and 2 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 [[ "${INPUT_FORCEORPHAN}" == "true" ]]; 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
@@ -110,5 +116,10 @@ else
git commit --allow-empty -m "${COMMIT_MESSAGE}"
fi
git push origin "${remote_branch}"
if [[ ${INPUT_FORCEORPHAN} == "true" ]]; then
git push origin --force "${remote_branch}"
else
git push origin "${remote_branch}"
fi
print_info "${GITHUB_SHA} was successfully deployed"