Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 28 additions & 4 deletions buildSrc/src/main/kotlin/netlify.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,34 @@ tasks.register<DefaultTask>("publishDocumentationToNetlify") {
val outputLines = output.orEmpty()
.replace("\\x1B\\[([0-9]{1,3}(;[0-9]{1,2};?)?)?[mGK]".toRegex(), "") // Removes ANSI colors from output
.split("\n")
// Output displays "Website draft URL" for draft deployments and "Website URL" for prod deployments
val netlifyDeployPreviewUrl = outputLines.firstNotNullOfOrNull { "^Website (?:draft |)URL:\\s+(.*)$".toRegex().find(it) }
?.groupValues
?.getOrNull(1)

// Output displays "Deployed draft to" for draft deployments and "Unique deploy URL" for prod deployments:
//
// ╭───────────────────────── ⬥ Draft deploy is live ⬥ ──────────────────────────╮
// │ │
// │ Deployed draft to │
// │ https://687672e116cf5a2cbd949f0a--ouds-android.netlify.app │
// │ │
// ╰───────────────────────────────────────────────────────────────────────────────╯
//
// ╭──────────────── ⬥ Production deploy is live ⬥ ─────────────────╮
// │ │
// │ Deployed to production URL: https://ouds-android.netlify.app │
// │ │
// │ Unique deploy URL: │
// │ https://687673f72c25433090a8bc6e--ouds-android.netlify.app │
// │ │
// ╰──────────────────────────────────────────────────────────────────╯
val netlifyDeployPreviewUrl = outputLines.indexOfFirst { it.contains("Deployed draft to") || it.contains("Unique deploy URL") }
.takeIf { it != -1 }
?.plus(1) // Deploy preview URL is displayed on the next line
?.let { index ->
"(https:\\/\\/.*--ouds-android\\.netlify\\.app)".toRegex()
.find(outputLines[index])
?.groupValues
?.getOrNull(1)
}

val netlifyDeployLogUrl = outputLines.firstNotNullOfOrNull { "^Build logs:\\s+(.*)$".toRegex().find(it) }
?.groupValues
?.getOrNull(1)
Expand Down
Loading