Skip to content

Commit c663275

Browse files
Fix inputs with empty string (#9)
* check presence * check input type
1 parent f469882 commit c663275

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/index.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@
22
require 'octokit'
33
require_relative './services/merge_branch_service'
44

5+
def presence(value)
6+
return nil if value == ""
7+
value
8+
end
9+
510
@event = JSON.parse(File.read(ENV['GITHUB_EVENT_PATH']))
6-
@head_to_merge = ENV['INPUT_HEAD_TO_MERGE'] || ENV['INPUT_FROM_BRANCH'] || ENV['GITHUB_SHA'] # or brach name
11+
@head_to_merge = presence(ENV['INPUT_HEAD_TO_MERGE']) || presence(ENV['INPUT_FROM_BRANCH']) || presence(ENV['GITHUB_SHA']) # or brach name
712
@repository = ENV['GITHUB_REPOSITORY']
8-
@github_token = ENV['INPUT_GITHUB_TOKEN'] || ENV['GITHUB_TOKEN']
13+
@github_token = presence(ENV['INPUT_GITHUB_TOKEN']) || presence(ENV['GITHUB_TOKEN'])
914

1015
inputs = {
11-
type: ENV['INPUT_TYPE'] || MergeBrachService::TYPE_LABELED, # labeled | comment | now
16+
type: presence(ENV['INPUT_TYPE']) || MergeBrachService::TYPE_LABELED, # labeled | comment | now
1217
label_name: ENV['INPUT_LABEL_NAME'],
1318
target_branch: ENV['INPUT_TARGET_BRANCH']
1419
}

0 commit comments

Comments
 (0)