Module: Fastlane::Helper::Github
- Defined in:
- lib/fastlane/plugin/emerge/helper/github.rb
Constant Summary collapse
- GITHUB_EVENT_PR =
"pull_request".freeze
- GITHUB_EVENT_PUSH =
"push".freeze
Class Method Summary collapse
- .base_sha ⇒ Object
- .branch ⇒ Object
- .event_name ⇒ Object
- .github_event_data ⇒ Object
- .is_pull_request? ⇒ Boolean
- .is_push? ⇒ Boolean
- .is_supported_github_event? ⇒ Boolean
- .pr_number ⇒ Object
- .repo_name ⇒ Object
- .repo_owner ⇒ Object
- .sha ⇒ Object
Class Method Details
.base_sha ⇒ Object
36 37 38 39 40 |
# File 'lib/fastlane/plugin/emerge/helper/github.rb', line 36 def self.base_sha if is_pull_request? github_event_data.dig(:pull_request, :base, :sha) end end |
.branch ⇒ Object
46 47 48 |
# File 'lib/fastlane/plugin/emerge/helper/github.rb', line 46 def self.branch is_pull_request? ? github_event_data.dig(:pull_request, :head, :ref) : Git.branch end |
.event_name ⇒ Object
11 12 13 |
# File 'lib/fastlane/plugin/emerge/helper/github.rb', line 11 def self.event_name ENV['GITHUB_EVENT_NAME'] end |
.github_event_data ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/fastlane/plugin/emerge/helper/github.rb', line 60 def self.github_event_data github_event_path = ENV['GITHUB_EVENT_PATH'] UI.error!("GITHUB_EVENT_PATH is not set") if github_event_path.nil? unless File.exist?(github_event_path) UI.error!("File #{github_event_path} doesn't exist") end file_content = File.read(github_event_path) file_json = JSON.parse(file_content, symbolize_names: true) if ENV['DEBUG'] UI.("Parsed GitHub event data: #{file_json.inspect}") end file_json end |
.is_pull_request? ⇒ Boolean
20 21 22 |
# File 'lib/fastlane/plugin/emerge/helper/github.rb', line 20 def self.is_pull_request? event_name == GITHUB_EVENT_PR end |
.is_push? ⇒ Boolean
24 25 26 |
# File 'lib/fastlane/plugin/emerge/helper/github.rb', line 24 def self.is_push? event_name == GITHUB_EVENT_PUSH end |
.is_supported_github_event? ⇒ Boolean
15 16 17 18 |
# File 'lib/fastlane/plugin/emerge/helper/github.rb', line 15 def self.is_supported_github_event? UI.("GitHub event name: #{event_name}") is_pull_request? || is_push? end |
.pr_number ⇒ Object
42 43 44 |
# File 'lib/fastlane/plugin/emerge/helper/github.rb', line 42 def self.pr_number is_pull_request? ? github_event_data.dig(:number) : nil end |
.repo_name ⇒ Object
54 55 56 |
# File 'lib/fastlane/plugin/emerge/helper/github.rb', line 54 def self.repo_name github_event_data.dig(:repository, :full_name) end |
.repo_owner ⇒ Object
50 51 52 |
# File 'lib/fastlane/plugin/emerge/helper/github.rb', line 50 def self.repo_owner github_event_data.dig(:repository, :owner, :login) end |
.sha ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/fastlane/plugin/emerge/helper/github.rb', line 28 def self.sha if is_push? ENV['GITHUB_SHA'] elsif is_pull_request? github_event_data.dig(:pull_request, :head, :sha) end end |