Skip to content

build: fix branch checkout for publish script #12585

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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