Skip to content

Commit

Permalink
Merge pull request #45 from henryz00/master
Browse files Browse the repository at this point in the history
Resolve SRC and DST repo name conflict
  • Loading branch information
andstor authored Jul 2, 2020
2 parents 0d78a5b + 02e7ebe commit 5d574b9
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ SRC_REPO_NAME="${GITHUB_REPOSITORY#*/}${SRC_WIKI}"
DST_REPO="${DST_OWNER}/${DST_REPO_NAME}${DST_WIKI}"
DST_REPO_NAME="${DST_REPO_NAME}${DST_WIKI}"

DST_REPO_DIR=dst_repo_dir
FINAL_SOURCE="${SRC_REPO_NAME}/${SRC_PATH}"

git config --global user.name "${USERNAME}"
Expand Down Expand Up @@ -113,12 +114,13 @@ if [[ -n "$FILTER" ]]; then
cd ..
fi

git clone --branch ${DST_BRANCH} --single-branch --depth 1 https://${PERSONAL_TOKEN}@github.com/${DST_REPO}.git

git clone --branch ${DST_BRANCH} --single-branch --depth 1 https://${PERSONAL_TOKEN}@github.com/${DST_REPO}.git ${DST_REPO_DIR}
if [ "$?" -ne 0 ]; then
echo >&2 "Cloning branch '$DST_BRANCH' in '$DST_REPO' failed"
echo >&2 "Falling back to default branch"
git clone --single-branch --depth 1 https://${PERSONAL_TOKEN}@github.com/${DST_REPO}.git
cd ${DST_REPO_NAME} || exit "$?"
git clone --single-branch --depth 1 https://${PERSONAL_TOKEN}@github.com/${DST_REPO}.git ${DST_REPO_DIR}
cd ${DST_REPO_DIR} || exit "$?"
echo >&2 "Creating branch '$DST_BRANCH'"
git checkout -b ${DST_BRANCH}
if [ "$?" -ne 0 ]; then
Expand All @@ -129,18 +131,18 @@ if [ "$?" -ne 0 ]; then
fi

if [ "$CLEAN" = "true" ]; then
if [ -f "${DST_REPO_NAME}/${DST_PATH}" ] ; then
find "${DST_REPO_NAME}/${DST_PATH}" -type f -not -path '*/\.git/*' -delete
elif [ -d "${DST_REPO_NAME}/${DST_PATH}" ] ; then
find "${DST_REPO_NAME}/${DST_PATH%/*}"/* -type f -not -path '*/\.git/*' -delete
if [ -f "${DST_REPO_DIR}/${DST_PATH}" ] ; then
find "${DST_REPO_DIR}/${DST_PATH}" -type f -not -path '*/\.git/*' -delete
elif [ -d "${DST_REPO_DIR}/${DST_PATH}" ] ; then
find "${DST_REPO_DIR}/${DST_PATH%/*}"/* -type f -not -path '*/\.git/*' -delete
else
echo >&2 "Nothing to clean 🧽"
fi
fi

mkdir -p "${DST_REPO_NAME}/${DST_PATH%/*}" || exit "$?"
cp -rf "${FINAL_SOURCE}" "${DST_REPO_NAME}/${DST_PATH}" || exit "$?"
cd ${DST_REPO_NAME} || exit "$?"
mkdir -p "${DST_REPO_DIR}/${DST_PATH%/*}" || exit "$?"
cp -rf "${FINAL_SOURCE}" "${DST_REPO_DIR}/${DST_PATH}" || exit "$?"
cd "${DST_REPO_DIR}" || exit "$?"

if [[ -z "${COMMIT_MESSAGE}" ]]; then
if [ -f "${BASE_PATH}/${FINAL_SOURCE}" ]; then
Expand Down

0 comments on commit 5d574b9

Please sign in to comment.