|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Get a github access token for the git checkout. |
| 4 | +echo "Getting github token..." |
| 5 | +# clone drivers-evergreen-tools to get this get-access-token script... |
| 6 | +tools="../../../drivers-evergreen-tools" |
| 7 | +git clone https://github.com/mongodb-labs/drivers-evergreen-tools.git $tools |
| 8 | + |
| 9 | +owner="mongodb" |
| 10 | +repo="mongo-python-driver" |
| 11 | +token=$(bash $tools/.evergreen/github_app/get-access-token.sh $repo $owner) |
| 12 | +if [ -z "${token}" ]; then |
| 13 | + echo "Failed to get github access token!" |
| 14 | + exit 1 |
| 15 | +fi |
| 16 | +echo "Getting github token... done." |
| 17 | + |
| 18 | +# Make the git checkout and create a new branch. |
| 19 | +echo "Creating the git checkout..." |
| 20 | +branch="spec-resync-"$(date '+%m-%d-%Y') |
| 21 | +body="$(cat spec_sync.txt)" |
| 22 | + |
| 23 | +git config user.email "167856002+mongodb-dbx-release-bot[bot]@users.noreply.github.com" |
| 24 | +git config user.name "mongodb-dbx-release-bot[bot]" |
| 25 | +git remote set-url origin https://x-access-token:${token}@github.com/$owner/$repo.git |
| 26 | +git checkout -b $branch "origin/main" |
| 27 | +echo "Creating the git checkout... done." |
| 28 | + |
| 29 | +git push origin $branch |
| 30 | +resp=$(curl -L \ |
| 31 | + -X POST \ |
| 32 | + -H "Accept: application/vnd.github+json" \ |
| 33 | + -H "Authorization: Bearer $token" \ |
| 34 | + -H "X-GitHub-Api-Version: 2022-11-28" \ |
| 35 | + -d "{\"title\":\"[Spec Resync] $(date '+%m-%d-%Y')\",\"body\":\"${body}\",\"head\":\"${branch}\",\"base\":\"main\"}" \ |
| 36 | + --url https://api.github.com/repos/$owner/$repo/pulls) |
| 37 | +echo $resp | jq '.html_url' |
| 38 | +echo "Creating the PR... done." |
| 39 | + |
| 40 | +rm -rf $dirname |
0 commit comments