Skip to content
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

ci: add script to open pr to update bazel builder version #92348

Merged
merged 1 commit into from
Nov 29, 2022
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash
set -xeuo pipefail

# This script expects the following env vars to be set:
# BRANCH [branch name to be created in fork]
# VERSION [new version to echo into build/.bazelbuilderversion]
# GH_TOKEN [github token]

dir="$(dirname $(dirname $(dirname $(dirname $(dirname $(dirname "${0}"))))))"
source "$dir/teamcity-common-support.sh"

git_ssh() {
# $@ passes all arguments to this function to the command
GIT_SSH_COMMAND="ssh -i $dir/.cockroach-teamcity-key" git "$@"
}

# Install `gh` tool.
wget -O /tmp/gh.tar.gz https://github.com/cli/cli/releases/download/v2.13.0/gh_2.13.0_linux_amd64.tar.gz
echo "9e833e02428cd49e0af73bc7dc4cafa329fe3ecba1bfe92f0859bf5b11916401 /tmp/gh.tar.gz" | sha256sum -c -
tar --strip-components 1 -xf /tmp/gh.tar.gz
export PATH=$PWD/bin:$PATH

# Configure git.
git config --global user.email "[email protected]"
git config --global user.name "cockroach-teamcity"
configure_git_ssh_key
rail marked this conversation as resolved.
Show resolved Hide resolved
trap "rm -f $dir/.cockroach-teamcity-key" EXIT
WORKDIR="$(mktemp -d ./workdir.XXXXXX)"

git_ssh clone "ssh://[email protected]/cockroachdb/cockroach.git" "$WORKDIR/cockroach" && cd "$WORKDIR/cockroach"
rail marked this conversation as resolved.
Show resolved Hide resolved

# Push commit to fork.
git checkout -b "$BRANCH"
echo -n "$VERSION" > build/.bazelbuilderversion
git commit -a -m "ci: update bazel builder image

Release note: None
Epic: None"
git_ssh push "ssh://[email protected]/cockroach-teamcity/cockroach.git" $BRANCH
rail marked this conversation as resolved.
Show resolved Hide resolved

# Create PR.
gh pr create --fill --head="cockroach-teamcity:$BRANCH" --base="master"

rm -rf $WORKDIR