private static void DeployTv(string ns, string cmpEndpointUrl, string cmpApiKey, string token, string scope, string region) { var sourceDirectory = "C:\\app\\tv"; var targetDirectory = $"C:\\app\\{ns}-tv"; // Needed to ensure that Vercel project has unique name per namespace Directory.Move(sourceDirectory, targetDirectory); var cmd = new WindowsCommandLine(targetDirectory); // Remove project if already exists cmd.Run($"vercel remove {ns}-tv --token {token} --scope {scope} --yes"); // Create new project cmd.Run($"vercel link --confirm --token {token} --debug --scope {scope}"); // Configure env. variables cmd.Run( $"echo | set /p=\"{cmpEndpointUrl}\" | vercel env add NEXT_PUBLIC_CMP_PREVIEW_ENDPOINT_URL production --token {token} --scope {scope}"); cmd.Run( $"echo | set /p=\"{cmpApiKey}\" | vercel env add NEXT_PUBLIC_CMP_PREVIEW_API_KEY production --token {token} --scope {scope}"); cmd.Run( $"echo | set /p=\"https://{ns}-website.sitecoredemo.com\" | vercel env add NEXT_PUBLIC_WEBSITE_URL production --token {token} --scope {scope}"); // Deploy project files var output = cmd.Run($"vercel --confirm --debug --prod --no-clipboard --token {token} --scope {scope} --regions {region}"); if (output.Contains(ErrorText)) { throw new Exception($"An error has occurred when running DeployToVercel job: DeployTv"); } // Assign custom domain name cmd.Run($"vercel domains add {ns}-tv.sitecoredemo.com --token {token} --scope {scope}"); }
private static void DeployWebsite(string ns, string cdpClientKey, string cdpApiTargetEndpoint, string cdpProxyUrl, string token, string scope, string region) { var cm = Environment.GetEnvironmentVariable("PUBLIC_HOST_CM"); var js = Environment.GetEnvironmentVariable("SITECORE_JSS_EDITING_SECRET"); var sourceDirectory = "C:\\app\\rendering"; var targetDirectory = $"C:\\app\\{ns}-website"; // Needed to ensure that Vercel project has unique name per namespace Directory.Move(sourceDirectory, targetDirectory); var cmd = new WindowsCommandLine(targetDirectory); // Remove project if already exists cmd.Run($"vercel remove {ns}-website --token {token} --scope {scope} --yes"); // Create new project cmd.Run($"vercel link --confirm --token {token} --debug --scope {scope}"); var productionUrl = $"https://{ns}-website-{scope}.vercel.app"; // Configure env. variables cmd.Run( $"echo | set /p=\"{productionUrl}\" | vercel env add PUBLIC_URL production --token {token} --scope {scope}"); cmd.Run( $"echo | set /p=\"{cm}\" | vercel env add SITECORE_API_HOST production --token {token} --scope {scope}"); cmd.Run( $"echo | set /p=\"{SitecoreApiKey}\" | vercel env add SITECORE_API_KEY production --token {token} --scope {scope}"); cmd.Run( $"echo | set /p=\"{js}\" | vercel env add JSS_EDITING_SECRET production --token {token} --scope {scope}"); cmd.Run( $"echo | set /p=\"{cdpClientKey}\" | vercel env add NEXT_PUBLIC_CDP_CLIENT_KEY production --token {token} --scope {scope}"); cmd.Run( $"echo | set /p=\"{cdpApiTargetEndpoint}\" | vercel env add NEXT_PUBLIC_CDP_API_TARGET_ENDPOINT production --token {token} --scope {scope}"); cmd.Run( $"echo | set /p=\"{cdpProxyUrl}\" | vercel env add NEXT_PUBLIC_CDP_PROXY_URL production --token {token} --scope {scope}"); // Deploy project files var output = cmd.Run($"vercel --confirm --debug --prod --no-clipboard --token {token} --scope {scope} --regions {region}"); if (output.Contains(ErrorText)) { throw new Exception($"An error has occurred when running DeployToVercel job: DeployWebsite"); } // Assign custom domain name cmd.Run($"vercel domains add {ns}-website.sitecoredemo.com --token {token} --scope {scope}"); }
public async Task Run() { if (this.IsCompleted()) { Log.LogWarning($"{this.GetType().Name} is already complete, it will not execute this time"); return; } var ns = Environment.GetEnvironmentVariable("RELEASE_NAMESPACE"); if (string.IsNullOrEmpty(ns)) { Log.LogWarning($"{this.GetType().Name} will not execute this time, RELEASE_NAMESPACE is not configured - this job is only required on AKS"); return; } var token = Environment.GetEnvironmentVariable("ID_SERVER_DEMO_CLIENT_SECRET"); if (string.IsNullOrEmpty(token)) { Log.LogWarning($"{this.GetType().Name} will not execute ID_SERVER_DEMO_CLIENT_SECRET is not configured"); return; } var cm = Environment.GetEnvironmentVariable("PUBLIC_HOST_CM"); var id = Environment.GetEnvironmentVariable("PUBLIC_HOST_ID"); if (string.IsNullOrEmpty(cm) || string.IsNullOrEmpty(id)) { Log.LogWarning($"{this.GetType().Name} will not execute, PUBLIC_HOST_CM and PUBLIC_HOST_ID are not configured"); return; } var cmd = new WindowsCommandLine("C:\\app"); Console.WriteLine(cmd.Run( $"dotnet sitecore login --client-credentials true --auth {id} --cm {cm} --allow-write true --client-id \"Demo_Automation\" --client-secret \"{token}\" -t")); Console.WriteLine(cmd.Run($"dotnet sitecore index schema-populate")); Console.WriteLine(cmd.Run($"dotnet sitecore index schema-populate")); Console.WriteLine(cmd.Run($"dotnet sitecore index rebuild")); await Complete(); }