ZanderZhao/gitbook-action

Setting publish_remove_last_build: true and publish_dir not / generates error from cp

Closed this issue · 1 comments

I am using the following settings:

publish_dir: draft
publish_remove_last_build: true

With this setting, the directory ./local_publish/draft is created with mkdir, then ./local_publish/draft is
deleted with git rm command. This then generates an error in the cp command because
./local_publish/draft is no longer present. I see the following in the build log:

cp: target 'local_publish/draft' is not a directory

Does the order of the mkdir and git rm commands need to be reversed in the publish section of entrypoint.sh?

######################### For publish #########################################

# if branch is new, need pubilsh_dir(if not /)
if [ ! -d "./local_publish/${INPUT_PUBLISH_DIR}" ] ; then
  mkdir ./local_publish/${INPUT_PUBLISH_DIR}
fi

#  need or not gitbook build history
if [ ${INPUT_PUBLISH_REMOVE_LAST_BUILD} = "true" ] ; then
  cd local_publish
  git rm -rf --ignore-unmatch  ./${INPUT_PUBLISH_DIR}/*
#  git rm -rf --ignore-unmatch  ./${INPUT_PUBLISH_DIR}/.*
  cd ..
fi

# move build file to each publish dir
cp -rfp local_source/_book/.  local_publish/${INPUT_PUBLISH_DIR}

Thank you, It has been fixed in version v1.2.4