Skip to content

Commit

Permalink
build: fix branch checkout for publish script (#12585)
Browse files Browse the repository at this point in the history
  • Loading branch information
devversion authored and josephperrott committed Aug 8, 2018
1 parent fca1429 commit e09ec34
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions scripts/deploy/publish-build-artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,22 @@ publishPackage() {

echo "Starting cloning process of ${repoUrl} into ${repoDir}.."

# Clone the repository and only fetch the last commit to download less unused data.
git clone ${repoUrl} ${repoDir} --depth 1
if [[ $(git ls-remote --heads ${repoUrl} ${branchName}) ]]; then
echo "Branch ${branchName} already exists. Cloning that branch."
git clone ${repoUrl} ${repoDir} --depth 1 --branch ${branchName}

echo "Successfully cloned ${repoUrl} into ${repoDir}."
cd ${repoDir}
echo "Cloned repository and switched into the repository directory (${repoDir})."
else
echo "Branch ${branchName} does not exist on ${packageRepo} yet."
echo "Cloning default branch and creating branch '${branchName}' on top of it."

# Create the build commit and push the changes to the repository.
cd ${repoDir}
git clone ${repoUrl} ${repoDir} --depth 1
cd ${repoDir}

echo "Switched into the repository directory (${repoDir})."
echo "Cloned repository and switched into directory. Creating new branch now.."

if [[ $(git ls-remote --heads origin ${branchName}) ]]; then
git checkout ${branchName}
echo "Switched to ${branchName} branch."
else
echo "Branch ${branchName} does not exist on ${packageRepo} yet. Creating ${branchName}.."
git checkout -b ${branchName}
echo "Branch created and checked out."
fi

# Copy the build files to the repository
Expand Down

0 comments on commit e09ec34

Please sign in to comment.