Skip to content

Commit 684c7b7

Browse files
committed
Fall back to GitHub-provided environment variable when running in GHA
1 parent b30a546 commit 684c7b7

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Package.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,10 @@ extension Array where Element == PackageDescription.CXXSetting {
479479
result.append(.define("SWT_TESTING_LIBRARY_COMMIT_HASH", to: #""\#(git.currentCommit)""#))
480480
if git.hasUncommittedChanges {
481481
result.append(.define("SWT_TESTING_LIBRARY_COMMIT_MODIFIED", to: "1"))
482+
} else if let gitHubSHA = Context.environment["GITHUB_SHA"] {
483+
// When building in GitHub Actions, the git command may fail to get us the
484+
// commit hash, so check if GitHub shared it with us instead.
485+
result.append(.define("SWT_TESTING_LIBRARY_COMMIT_HASH", to: #""\#(gitHubSHA)""#))
482486
}
483487
}
484488

0 commit comments

Comments
 (0)