Skip to content

Commit dd96bb5

Browse files
committed
Forward draft parameter in find_or_create_pull_request
Allow creating draft PRs by forwarding a draft option to the underlying create_pull_request action.
1 parent 4b39f7d commit dd96bb5

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

lib/fastlane/plugin/wpmreleasetoolkit/actions/common/find_or_create_pull_request_action.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def self.run(params)
2626
repo: params[:repository],
2727
title: params[:title],
2828
body: params[:body],
29+
draft: params[:draft],
2930
head: params[:head],
3031
base: params[:base],
3132
labels: params[:labels],
@@ -67,6 +68,7 @@ def self.available_options
6768
# Parameters we forward as-is from Fastlane's `create_pull_request` action
6869
forwarded_param_keys = %i[
6970
api_url
71+
draft
7072
labels
7173
assignees
7274
reviewers

spec/find_or_create_pull_request_spec.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
repo: test_repo,
4545
title: 'Update translations',
4646
body: 'Sync translations from GlotPress',
47+
draft: nil,
4748
head: test_head,
4849
base: test_base,
4950
labels: ['Localization'],
@@ -65,5 +66,23 @@
6566

6667
expect(result).to eq("https://github.com/#{test_repo}/pull/8")
6768
end
69+
70+
it 'forwards draft: true when creating a draft PR' do
71+
allow(github_helper).to receive(:find_pull_request).and_return(nil)
72+
allow(other_action_mock).to receive(:create_pull_request)
73+
.with(hash_including(draft: true))
74+
.and_return("https://github.com/#{test_repo}/pull/9")
75+
76+
result = run_described_fastlane_action(
77+
github_token: test_token,
78+
repository: test_repo,
79+
title: 'Update translations',
80+
head: test_head,
81+
base: test_base,
82+
draft: true
83+
)
84+
85+
expect(result).to eq("https://github.com/#{test_repo}/pull/9")
86+
end
6887
end
6988
end

0 commit comments

Comments
 (0)