Skip to content

Commit

Permalink
chore: push current branch to remote (#3455)
Browse files Browse the repository at this point in the history
Fix error when updating googleapis commit in a new branch.
```
fatal: unknown commit origin/generate-libraries-main
```

Example run:
https://github.com/googleapis/sdk-platform-java/actions/runs/12286920597/job/34287983045
  • Loading branch information
JoeWang1127 authored Dec 12, 2024
1 parent d7579ba commit 18473a7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .github/scripts/update_googleapis_commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ pr_num=$(gh pr list -s open -H "${current_branch}" -q . --json number | jq ".[]
# branch; otherwise checkout the pull request.
if [ -z "${pr_num}" ]; then
git checkout -b "${current_branch}"
# Push the current branch to remote so that we can
# compare the commits later.
git push -u origin "${current_branch}"
else
gh pr checkout "${pr_num}"
fi
Expand Down Expand Up @@ -102,7 +105,7 @@ fi

if [ -z "${pr_num}" ]; then
git remote add remote_repo https://cloud-java-bot:"${GH_TOKEN}@github.com/${repo}.git"
git fetch -q --unshallow remote_repo
git fetch -q remote_repo
git push -f remote_repo "${current_branch}"
gh pr create --title "${title}" --head "${current_branch}" --body "${title}" --base "${base_branch}"
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ pr_num=$(gh pr list -s open -H "${current_branch}" -q . --json number | jq ".[]
# branch; otherwise checkout the pull request.
if [ -z "${pr_num}" ]; then
git checkout -b "${current_branch}"
# Push the current branch to remote so that we can
# compare the commits later.
git push -u origin "${current_branch}"
else
gh pr checkout "${pr_num}"
fi
Expand Down Expand Up @@ -156,7 +159,7 @@ fi

if [ -z "${pr_num}" ]; then
git remote add remote_repo https://cloud-java-bot:"${GH_TOKEN}@github.com/${repo}.git"
git fetch -q --unshallow remote_repo
git fetch -q remote_repo
git push -f remote_repo "${current_branch}"
gh pr create --title "${title}" --head "${current_branch}" --body "${title}" --base "${base_branch}"
else
Expand Down

0 comments on commit 18473a7

Please sign in to comment.