Skip to content

Commit

Permalink
Yup
Browse files Browse the repository at this point in the history
  • Loading branch information
gwynne committed Oct 14, 2023
1 parent f552e80 commit 08bf216
Showing 1 changed file with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,23 @@ struct GithubDependencyGraph: Codable {
job: Job, detector: Detector, scanned: Date, manifests: [String: Manifest]
}

func env(_ name: String) -> String? { ProcessInfo.processInfo.environment[name] }
func env(_ name: String) -> String {
guard let value = ProcessInfo.processInfo.environment[name] else {
try? FileHandle.standardError.write(contentsOf: Array("Incomplete environment: \(name).\n".utf8))
exit(1)
}
}

func main() {
let decoder = JSONDecoder(), encoder = JSONEncoder()
decoder.dateDecodingStrategy = .iso8601
encoder.dateEncodingStrategy = .iso8601
encoder.outputFormatting = [.withoutEscapingSlashes, .sortedKeys]

guard let owner = env("OWNER"), let repo = env("REPO"),
let branch = env("BRANCH"), let commit = env("COMMIT"),
let correlator = env("CORRELATOR"), let runId = env("RUN_ID"),
let detector = env("GITHUB_ACTION"),
let detectorVer = env("GITHUB_ACTION_REF"),
let detectorRepo = env("GITHUB_ACTION_REPOSITORY"),
let serverUrl = env("GITHUB_SERVER_URL")
else {
try? FileHandle.standardError.write(contentsOf: Array("Incomplete environment.\n".utf8))
exit(1)
}
let owner = env("OWNER"), repo = env("REPO"), branch = env("BRANCH"),
commit = env("COMMIT"), correlator = env("CORRELATOR"), runId = env("RUN_ID"),
detector = env("GITHUB_ACTION"), detectorVer = env("GITHUB_ACTION_REF"),
detectorRepo = env("GITHUB_ACTION_REPOSITORY"), serverUrl = env("GITHUB_SERVER_URL")

let dependencies = try! decoder.decode(
PackageDependency.self,
Expand Down

0 comments on commit 08bf216

Please sign in to comment.