Skip to content

Commit

Permalink
Fix existence check and cleanup (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
at-wat authored Jan 4, 2020
1 parent 23e55a3 commit 3bfbe8f
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,27 @@ then
INPUT_VERSION=$(echo ${INPUT_ISSUE_TITLE} | sed -e 's/^Release \(.*\)$/\1/')
fi

function cleanup() {
if [[ "${GITHUB_REF}" == refs/heads/* ]]
then
git checkout ${GITHUB_REF}
else
# Detach head to work with repo-sync/pull-request
git checkout refs/heads/${GITHUB_REF}
fi
git branch -D release-${INPUT_VERSION} || true
}

# Check duplication
if ! git ls-remote --exit-code origin ${INPUT_VERSION}
if git ls-remote --exit-code origin ${INPUT_VERSION}
then
echo "Release already exists. Nothing to do." >&2
cleanup
exit 0
fi

update=false
if ! git ls-remote --exit-code origin release-${INPUT_VERSION}
if git ls-remote --exit-code origin release-${INPUT_VERSION}
then
echo "Release candidate branch already exists. Updating." >&2
update=true
Expand Down Expand Up @@ -79,11 +91,4 @@ echo "::set-output name=created_branch::release-${INPUT_VERSION}"
echo "::set-output name=version::${INPUT_VERSION}"

# Clean-up
if [[ "${GITHUB_REF}" == refs/heads/* ]]
then
git checkout ${GITHUB_REF}
else
# Detach head to work with repo-sync/pull-request
git checkout refs/heads/${GITHUB_REF}
fi
git branch -D release-${INPUT_VERSION}
cleanup

0 comments on commit 3bfbe8f

Please sign in to comment.