From 7216888f953c56b012170355a412ad353401f3ca Mon Sep 17 00:00:00 2001 From: peaceiris <30958501+peaceiris@users.noreply.github.com> Date: Thu, 17 Oct 2019 07:41:16 +0900 Subject: [PATCH] feat: Add INPUT_FORCEORPHAN, close #42 --- action.yml | 4 ++++ entrypoint.sh | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index c776467..7b9da8a 100644 --- a/action.yml +++ b/action.yml @@ -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' diff --git a/entrypoint.sh b/entrypoint.sh index d72e63d..93a5612 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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