diff --git a/ci/deploy.ps1 b/ci/deploy.ps1 index 47e725bc..da9bcb4f 100644 --- a/ci/deploy.ps1 +++ b/ci/deploy.ps1 @@ -73,26 +73,38 @@ pushd "spatial" Write-Log "Failed to launch a Spatial cloud deployment. Error: $($launch_deployment_process.ExitCode)" Throw "Deployment launch failed" } + } else { + Write-Log "Deployment will not be launched as you have passed in an argument specifying that it should not be (START_DEPLOYMENT=${launch_deployment}). Remove it to have your build launch a deployment." + } + if ($env:BUILDKITE_BRANCH -eq "master" -or $env:BUILDKITE_SLACK_NOTIFY -eq "true") { # Send a Slack notification with a link to the new deployment and to the build. + + # Build Slack text + if ($env:BUILDKITE_NIGHTLY_BUILD -eq "true") { + $slack_text = ":night_with_stars: Nightly build of *Example Project* succeeded." + } else { + $slack_text = "*Example Project* build by $env:BUILDKITE_BUILD_CREATOR succeeded." + } + # Read Slack webhook secret from the vault and extract the Slack webhook URL from it. $slack_webhook_secret = "$(imp-ci secrets read --environment=production --buildkite-org=improbable --secret-type=slack-webhook --secret-name=unreal-gdk-slack-web-hook)" $slack_webhook_url = $slack_webhook_secret | ConvertFrom-Json | %{$_.url} $deployment_url = "https://console.improbable.io/projects/${project_name}/deployments/${deployment_name}/overview" - $gdk_commit_url = "https://github.com/spatialos/UnrealGDK/tree/${gdk_commit_hash}" + $gdk_commit_url = "https://github.com/spatialos/UnrealGDK/commit/${gdk_commit_hash}" + $project_commit_url = "https://github.com/spatialos/UnrealGDKExampleProject/commit/$env:BUILDKITE_COMMIT" $build_url = "$env:BUILDKITE_BUILD_URL" - $json_message = [ordered]@{ - text = "Example Project build created by $env:BUILDKITE_BUILD_CREATOR succeeded and a deployment has been launched." + text = "$slack_text" attachments= @( @{ - fallback = "Find deployment here: $deployment_url and build here: $build_url" + fallback = "Find build here: $build_url and potential deployment here: $deployment_url" color = "good" - fields= @( + fields = @( @{ - title = "GDK branch" - value = "$gdk_branch_name" + title = "Build Message" + value = "$env:BUILDKITE_MESSAGE" short = "true" } @{ @@ -100,23 +112,28 @@ pushd "spatial" value = "$env:BUILDKITE_BRANCH" short = "true" } + @{ + title = "GDK branch" + value = "$gdk_branch_name" + short = "true" + } ) - actions= @( + actions = @( @{ type = "button" - text = "Take me to the deployment" - url = "$deployment_url" + text = ":github: Project commit" + url = "$project_commit_url" style = "primary" } @{ type = "button" - text = "Take me to the GDK commit" + text = ":github: GDK commit" url = "$gdk_commit_url" style = "primary" } @{ type = "button" - text = "Take me to the build" + text = ":buildkite: BK build" url = "$build_url" style = "primary" } @@ -125,15 +142,20 @@ pushd "spatial" ) } + if ($launch_deployment -eq "true") { + $deployment_button = @{ + type = "button" + text = ":cloud: View deployment" + url = "$deployment_url" + style = "primary" + } + $json_message["attachments"][0]["actions"] += ($deployment_button) + } + $json_request = $json_message | ConvertTo-Json -Depth 10 Invoke-WebRequest -UseBasicParsing "$slack_webhook_url" -ContentType "application/json" -Method POST -Body "$json_request" - } - else { - Write-Log "Deployment will not be launched as you have passed in an argument specifying that it should not be (START_DEPLOYMENT=${launch_deployment}). Remove it to have your build launch a deployment." - } - Finish-Event "launch-deployment" "deploy-unreal-gdk-example-project-:windows:" popd