Class: Fastlane::Actions::CurrentBranchAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/stream_actions/actions/current_branch.rb

Documentation collapse

Class Method Summary collapse

Class Method Details

.available_optionsObject



23
24
25
26
27
28
29
30
31
32
# File 'lib/fastlane/plugin/stream_actions/actions/current_branch.rb', line 23

def self.available_options
  [
    FastlaneCore::ConfigItem.new(
      env_name: 'GITHUB_PR_NUM',
      key: :pr_num,
      description: 'GitHub PR number',
      optional: true
    )
  ]
end

.descriptionObject



19
20
21
# File 'lib/fastlane/plugin/stream_actions/actions/current_branch.rb', line 19

def self.description
  'Get current branch name'
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/fastlane/plugin/stream_actions/actions/current_branch.rb', line 34

def self.is_supported?(platform)
  true
end

.run(params) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'lib/fastlane/plugin/stream_actions/actions/current_branch.rb', line 4

def self.run(params)
  branch = if params[:pr_num].to_s.empty?
             other_action.git_branch
           else
             sh("gh pr view #{params[:pr_num]} --json headRefName -q .headRefName").strip
           end

  UI.important("Current branch: #{branch} 🕊️")
  branch
end