Skip to content
Draft
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
17 changes: 10 additions & 7 deletions .buildkite/scripts/backport_branch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,6 @@ updateBackportBranchContents() {
git checkout "$SOURCE_BRANCH" -- "magefile.go"
git add magefile.go

# As this script runs in the context of the main branch (mainly go mod tidy), we need to copy
# the .go-version file from the main branch to the backport branch. This avoids failures
# installing dependencies in the backport Pull Request.
echo "--- Copying .go-version from $SOURCE_BRANCH..."
git checkout "$SOURCE_BRANCH" -- ".go-version"
git add .go-version

# Restore workflows from the main branch since modifying them requires extra permissions.
# > error: GH013: Repository rule violations found for ...
# > refusing to allow a GitHub App to create or update workflow `.github/workflows/bump-elastic-stack-version.yml` without `workflows` permission
Expand All @@ -193,9 +186,19 @@ updateBackportBranchContents() {

# Run go mod tidy to update just the dependencies related to magefile and dev scripts
echo "--- Running go mod tidy to update dependencies related to magefile and dev scripts..."
# Switch to the backport branch's Go version so go mod tidy keeps go.mod as-is.
eval "$(gvm "$(cat .go-version)")"
echo "Setting go version from backport branch"
go version

go mod tidy

git add go.mod go.sum

# Restore the Go version from the source branch for the rest of the script execution.
echo "Restoring go version from ${SOURCE_BRANCH} branch"
eval "$(gvm "$(git show "${SOURCE_BRANCH}:.go-version")")"
go version
fi

if [ "${REMOVE_OTHER_PACKAGES}" == "true" ]; then
Expand Down
Loading