Class: ActionReporter::TrackingIssueOutput

Inherits:
Object
  • Object
show all
Defined in:
action/lib/action_reporter.rb

Overview

Writes tracking-issue outputs for runs that created or updated one.

Class Method Summary collapse

Class Method Details

.write(result) ⇒ Object



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'action/lib/action_reporter.rb', line 123

def self.write(result)
  return unless result

  unless result.kind_of?(Hash) && result.key?(:number) && result.key?(:url)
    puts("Warning: tracking issue result was malformed; skipping tracking issue outputs")
    return
  end

  number = result[:number]
  url = result[:url]
  return if number.to_s.empty? || url.to_s.empty?

  output_path = WorkflowCommand.env_value("GITHUB_OUTPUT")
  return unless output_path

  File.open(output_path, "a") { |file|
    file.puts("tracking-issue-number=#{number}")
    file.puts("tracking-issue-url=#{url}")
  }
end