Skip to content

Commit 0fd20e6

Browse files
devversionmmalerba
authored andcommitted
build: fix branch checkout for publish script (#12585)
1 parent 0b185b1 commit 0fd20e6

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

scripts/deploy/publish-build-artifacts.sh

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,23 +58,22 @@ publishPackage() {
5858

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

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

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

66-
# Create the build commit and push the changes to the repository.
67-
cd ${repoDir}
71+
git clone ${repoUrl} ${repoDir} --depth 1
72+
cd ${repoDir}
6873

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

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

8079
# Copy the build files to the repository

0 commit comments

Comments
 (0)