diff --git a/buildSrc/src/main/kotlin/netlify.gradle.kts b/buildSrc/src/main/kotlin/netlify.gradle.kts index 1a21a18cb..3b85348ef 100644 --- a/buildSrc/src/main/kotlin/netlify.gradle.kts +++ b/buildSrc/src/main/kotlin/netlify.gradle.kts @@ -43,10 +43,34 @@ tasks.register("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)