mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Move CI GitHub token usage to the global git configuration
This commit is contained in:
committed by
Stefan Ceriu
parent
abb1274154
commit
519cd4052d
@@ -128,8 +128,13 @@ struct CI: ParsableCommand {
|
|||||||
// MARK: - Git
|
// MARK: - Git
|
||||||
|
|
||||||
static func gitConfigureGlobals() async throws {
|
static func gitConfigureGlobals() async throws {
|
||||||
|
guard let apiToken = ProcessInfo.processInfo.environment["GITHUB_TOKEN"], !apiToken.isEmpty else {
|
||||||
|
throw ValidationError("GITHUB_TOKEN environment variable is not set.")
|
||||||
|
}
|
||||||
|
|
||||||
try await CI.run(.name("git"), ["config", "--global", "user.name", "Element CI"])
|
try await CI.run(.name("git"), ["config", "--global", "user.name", "Element CI"])
|
||||||
try await CI.run(.name("git"), ["config", "--global", "user.email", "ci@element.io"])
|
try await CI.run(.name("git"), ["config", "--global", "user.email", "ci@element.io"])
|
||||||
|
try await CI.run(.name("git"), ["config", "--global", "http.extraHeader", "Authorization: Bearer \(apiToken)"])
|
||||||
}
|
}
|
||||||
|
|
||||||
static func gitRepositoryURL() async throws -> String {
|
static func gitRepositoryURL() async throws -> String {
|
||||||
@@ -145,20 +150,15 @@ struct CI: ParsableCommand {
|
|||||||
.replacingOccurrences(of: ".git", with: "")
|
.replacingOccurrences(of: ".git", with: "")
|
||||||
.trimmingCharacters(in: .whitespacesAndNewlines)
|
.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
}
|
}
|
||||||
|
|
||||||
static func gitPush(tagName: String? = nil) async throws {
|
|
||||||
guard let apiToken = ProcessInfo.processInfo.environment["GITHUB_TOKEN"], !apiToken.isEmpty
|
|
||||||
else {
|
|
||||||
throw ValidationError("GITHUB_TOKEN environment variable is not set.")
|
|
||||||
}
|
|
||||||
|
|
||||||
|
static func gitPush(tagName: String? = nil) async throws {
|
||||||
let repoURL = try await CI.gitRepositoryURL()
|
let repoURL = try await CI.gitRepositoryURL()
|
||||||
|
|
||||||
if let tagName {
|
if let tagName {
|
||||||
try await CI.run(.name("git"), ["tag", tagName])
|
try await CI.run(.name("git"), ["tag", tagName])
|
||||||
try await CI.run(.name("git"), ["push", "https://\(apiToken)@\(repoURL)", tagName])
|
try await CI.run(.name("git"), ["push", "https://\(repoURL)", tagName])
|
||||||
} else {
|
} else {
|
||||||
try await CI.run(.name("git"), ["push", "https://\(apiToken)@\(repoURL)"])
|
try await CI.run(.name("git"), ["push", "https://\(repoURL)"])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user