79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
# File 'lib/datadog/ci/ext/environment/providers/github_actions.rb', line 79
def additional_tags
base_ref = env["GITHUB_BASE_REF"]
return {} if base_ref.nil? || base_ref.empty?
result = {
Git::TAG_PULL_REQUEST_BASE_BRANCH => base_ref
}
event_path = env["GITHUB_EVENT_PATH"]
event_json = JSON.parse(File.read(event_path))
head_sha = event_json.dig("pull_request", "head", "sha")
result[Git::TAG_COMMIT_HEAD_SHA] = head_sha if head_sha
base_sha = event_json.dig("pull_request", "base", "sha")
result[Git::TAG_PULL_REQUEST_BASE_BRANCH_SHA] = base_sha if base_sha
result
rescue => e
Datadog.logger.error("Failed to extract additional tags from GitHub Actions: #{e}")
Core::Telemetry::Logger.report(e, description: "Failed to extract additional tags from GitHub Actions")
{}
end
|