Skip to content

Commit

Permalink
Don't include github annotations if not using gha
Browse files Browse the repository at this point in the history
  • Loading branch information
roddymunro committed Mar 15, 2024
1 parent b70d04a commit 7db4ea7
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions Sources/SwiftPolyglot/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ guard CommandLine.arguments.count > 1 else {
exit(1)
}

let isRunningFromGitHubActions = ProcessInfo.processInfo.environment["GITHUB_ACTIONS"] == "true"
let languages = CommandLine.arguments[1].split(separator: ",").map(String.init)
let errorOnMissing = CommandLine.arguments.contains("--errorOnMissing")

Expand All @@ -19,7 +20,11 @@ func checkTranslations(in fileURL: URL, for languages: [String]) {
let jsonDict = jsonObject as? [String: Any],
let strings = jsonDict["strings"] as? [String: [String: Any]]
else {
print("::warning file=\(fileURL.path)::Could not process file at path: \(fileURL.path)")
if isRunningFromGitHubActions {
print("::warning file=\(fileURL.path)::Could not process file at path: \(fileURL.path)")
} else {
print("Could not process file at path: \(fileURL.path)")
}
return
}

Expand Down Expand Up @@ -55,10 +60,14 @@ func searchDirectory(_ dirPath: String) {
}

func logWarning(file: String, message: String) {
if errorOnMissing {
print("::error file=\(file)::\(message)")
if isRunningFromGitHubActions {
if errorOnMissing {
print("::error file=\(file)::\(message)")
} else {
print("::warning file=\(file)::\(message)")
}
} else {
print("::warning file=\(file)::\(message)")
print(message)
}
}

Expand Down

0 comments on commit 7db4ea7

Please sign in to comment.