Skip to content

Commit 61ebc23

Browse files
authored
chore: enable fork for new-library and owlbot scripts (googleapis#22393)
1 parent e1ecbf2 commit 61ebc23

File tree

5 files changed

+27
-8
lines changed

5 files changed

+27
-8
lines changed

.github/workflows/new-library.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ jobs:
1717
steps:
1818
- name: Checkout repo
1919
uses: actions/checkout@v3
20-
- name: Install Ruby 3.1
20+
- name: Install Ruby 3.2
2121
uses: ruby/setup-ruby@v1
2222
with:
23-
ruby-version: "3.1"
23+
ruby-version: "3.2"
2424
- name: Install tools
2525
run: |
2626
git config --global user.email "70984784+yoshi-code-bot@users.noreply.github.com"
2727
git config --global user.name "Yoshi Code Bot"
2828
gem install --no-document toys
2929
- name: Create library
3030
run: |
31-
toys new-library -v --pull --test --remote=origin --bootstrap-releases ${{ github.event.inputs.protoPath }}
31+
toys new-library -v --pull --test --fork --bootstrap-releases ${{ github.event.inputs.protoPath }}

.github/workflows/obsolete-library.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ jobs:
2525
ruby-version: "3.2"
2626
- name: Install tools
2727
run: |
28+
git config --global user.email "70984784+yoshi-code-bot@users.noreply.github.com"
29+
git config --global user.name "Yoshi Code Bot"
2830
gem install --no-document toys
2931
- name: Obsolete-library
3032
run: |
31-
ruby -e 'require "digest"; puts Digest::MD5.hexdigest ENV["GITHUB_TOKEN"]'
3233
toys obsolete-library -v --fork ${{ github.event.inputs.flags }} ${{ github.event.inputs.gem }}

.github/workflows/owlbot.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ jobs:
2020
steps:
2121
- name: Checkout repo
2222
uses: actions/checkout@v3
23-
- name: Install Ruby 3.0
23+
- name: Install Ruby 3.2
2424
uses: ruby/setup-ruby@v1
2525
with:
26-
ruby-version: "3.0"
26+
ruby-version: "3.2"
2727
- name: Install tools
2828
run: |
2929
git config --global user.email "70984784+yoshi-code-bot@users.noreply.github.com"
3030
git config --global user.name "Yoshi Code Bot"
3131
gem install --no-document toys
3232
- name: OwlBot
3333
run: |
34-
toys owlbot -v --pull --remote=origin ${{ github.event.inputs.flags }} ${{ github.event.inputs.gems }}
34+
toys owlbot -v --pull --fork ${{ github.event.inputs.flags }} ${{ github.event.inputs.gems }}

.toys/new-library.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
flag :git_remote, "--remote NAME" do
4444
desc "The name of the git remote to use as the pull request head. If omitted, does not open a pull request."
4545
end
46+
flag :enable_fork, "--fork" do
47+
desc "Use a fork to open the pull request"
48+
end
4649
flag :enable_tests, "--[no-]test" do
4750
desc "Run CI on the newly-created library"
4851
end
@@ -81,6 +84,10 @@ def setup
8184
Dir.chdir context_directory
8285
error "#{owlbot_config_path} already exists" if File.file? owlbot_config_path
8386
yoshi_utils.git_ensure_identity
87+
if enable_fork
88+
set :git_remote, "pull-request-fork" unless git_remote
89+
yoshi_utils.gh_ensure_fork remote: git_remote
90+
end
8491
mkdir_p gem_name
8592
end
8693

.toys/owlbot.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@
3030
flag :git_remote, "--remote=NAME" do
3131
desc "The name of the git remote to use as the pull request head. If omitted, does not open a pull request."
3232
end
33+
flag :enable_fork, "--fork" do
34+
desc "Use a fork to open the pull request"
35+
end
3336
flag :commit_message, "--message=MESSAGE" do
3437
desc "The conventional commit message"
3538
end
@@ -76,7 +79,7 @@ def run
7679

7780
gems = choose_gems
7881
cd context_directory
79-
yoshi_utils.git_ensure_identity
82+
setup_git
8083
gem_info = collect_gem_info gems
8184

8285
pull_images
@@ -91,6 +94,14 @@ def run
9194
final_output results
9295
end
9396

97+
def setup_git
98+
yoshi_utils.git_ensure_identity
99+
if enable_fork
100+
set :git_remote, "pull-request-fork" unless git_remote
101+
yoshi_utils.gh_ensure_fork remote: git_remote
102+
end
103+
end
104+
94105
def ensure_docker
95106
result = exec ["docker", "--version"], out: :capture, e: false
96107
error "Docker not installed" unless result.success?

0 commit comments

Comments
 (0)