From 47a6d63ea8b47b19328e258563aa1fbe224c0a23 Mon Sep 17 00:00:00 2001 From: blue-jam Date: Mon, 16 Sep 2019 01:06:45 +0900 Subject: [PATCH] Fix: "git rm" fails when publish branch is empty (#24) When a publish branch exists and it has no files, `git rm -r '*'` fails with ``` fatal: pathspec '*' did not match any files ``` `--ignore-unmatch` option let git exit with a zero status in this case. Reference: https://git-scm.com/docs/git-rm#Documentation/git-rm.txt---ignore-unmatch --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 8376972..a0fdb97 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -55,7 +55,7 @@ remote_branch="${PUBLISH_BRANCH}" local_dir="${HOME}/$(tr -cd 'a-f0-9' < /dev/urandom | head -c 32)" if git clone --depth=1 --single-branch --branch "${remote_branch}" "${remote_repo}" "${local_dir}"; then cd "${local_dir}" - git rm -r '*' + git rm -r --ignore-unmatch '*' find "${GITHUB_WORKSPACE}/${PUBLISH_DIR}" -maxdepth 1 | \ tail -n +2 | \ xargs -I % cp -rf % "${local_dir}/"