private static async Task <Boolean> PushGithubAsync(BuildRequest br) { LogInfo("creating github files for dotnetcore " + br.Version); String timeStamp = DateTime.Now.ToString("yyyyMMddHHmmss"); String random = new Random().Next(0, 9999).ToString(); String parent = String.Format("D:\\local\\Temp\\blimp{0}{1}", timeStamp, random); _githubUtils.CreateDir(parent); String localTemplateRepoPath = String.Format("{0}\\{1}", parent, br.TemplateRepoName); String localOutputRepoPath = String.Format("{0}\\{1}", parent, br.OutputRepoName); _githubUtils.Clone(br.TemplateRepoURL, localTemplateRepoPath, br.TemplateRepoBranchName, br.PullRepo, br.PullId); _githubUtils.CreateDir(localOutputRepoPath); if (await _githubUtils.RepoExistsAsync(br.OutputRepoOrgName, br.OutputRepoName)) { _githubUtils.Clone( br.OutputRepoURL, localOutputRepoPath, br.OutputRepoBranchName); _githubUtils.Checkout(localOutputRepoPath, br.OutputRepoBranchName); } else { await _githubUtils.InitGithubAsync(br.OutputRepoOrgName, br.OutputRepoName); _githubUtils.Init(localOutputRepoPath); _githubUtils.AddRemote(localOutputRepoPath, br.OutputRepoOrgName, br.OutputRepoName); } _githubUtils.Delete(localOutputRepoPath, skipGit: true); _githubUtils.DeepCopy( String.Format("{0}\\{1}", localTemplateRepoPath, br.TemplateName), localOutputRepoPath); _githubUtils.DeepCopy( String.Format("{0}\\src\\{1}", localTemplateRepoPath, getZip(br.Version)), localOutputRepoPath); _githubUtils.CopyFile( String.Format("{0}\\src\\{1}\\bin.zip", localTemplateRepoPath, getZip(br.Version)), String.Format("{0}\\bin.zip", localOutputRepoPath), force: true); _githubUtils.FillTemplate( String.Format("{0}\\DockerFile", localOutputRepoPath), new List <String> { String.Format("FROM {0}", br.BaseImageName) }, new List <int> { 1 } ); _githubUtils.Stage(localOutputRepoPath, "*"); _githubUtils.CommitAndPush(localOutputRepoPath, br.OutputRepoBranchName, String.Format("[blimp] Add dotnetcore {0}", br.Version)); _githubUtils.gitDispose(localOutputRepoPath); _githubUtils.gitDispose(localTemplateRepoPath); _githubUtils.Delete(parent); LogInfo("done creating github files for dotnetcore " + br.Version); return(true); }
private static async System.Threading.Tasks.Task PushGithubAsync(BuildRequest br) { LogInfo("creating github files for ruby " + br.Version); String timeStamp = DateTime.Now.ToString("yyyyMMddHHmmss"); String random = new Random().Next(0, 9999).ToString(); String parent = String.Format("D:\\local\\Temp\\blimp{0}{1}", timeStamp, random); _githubUtils.CreateDir(parent); String localTemplateRepoPath = String.Format("{0}\\{1}", parent, br.TemplateRepoName); String localOutputRepoPath = String.Format("{0}\\{1}", parent, br.OutputRepoName); _githubUtils.Clone(br.TemplateRepoURL, localTemplateRepoPath, br.TemplateRepoBranchName, br.PullRepo, br.PullId); _githubUtils.CreateDir(localOutputRepoPath); if (await _githubUtils.RepoExistsAsync(br.OutputRepoOrgName, br.OutputRepoName)) { _githubUtils.Clone( br.OutputRepoURL, localOutputRepoPath, br.OutputRepoBranchName); _githubUtils.Checkout(localOutputRepoPath, br.OutputRepoBranchName); } else { await _githubUtils.InitGithubAsync(br.OutputRepoOrgName, br.OutputRepoName); _githubUtils.Init(localOutputRepoPath); _githubUtils.AddRemote(localOutputRepoPath, br.OutputRepoOrgName, br.OutputRepoName); } _githubUtils.Delete(localOutputRepoPath, skipGit: true); _githubUtils.DeepCopy( String.Format("{0}\\{1}", localTemplateRepoPath, br.TemplateName), localOutputRepoPath, false); _githubUtils.FillTemplate( String.Format("{0}\\DockerFile", localOutputRepoPath), new List <String> { String.Format("ENV RUBY_VERSION=\"{0}\"", br.Version) }, new List <int> { 4 }); _githubUtils.Stage(localOutputRepoPath, "*"); _githubUtils.CommitAndPush(localOutputRepoPath, br.OutputRepoBranchName, String.Format("[blimp] Add ruby {0}", br.Version)); _githubUtils.gitDispose(localOutputRepoPath); _githubUtils.gitDispose(localTemplateRepoPath); _githubUtils.Delete(parent); LogInfo("done creating github files for ruby " + br.Version); return; }
public string CreateWebappGitDeploy(String version, String acrPassword, String appName, String imageName, String planName, String targetRepo, GitHubUtils gitHubUtils) { int tries = 0; while (true) { try { //_log.Info("creating webapp"); _webappClient.WebApps.Delete(_rgName, appName, false, false); AppServicePlan plan = _webappClient.AppServicePlans.Get(_rgName, planName); //_log.Info("creating site :" + appName); _webappClient.WebApps.CreateOrUpdate(_rgName, appName, new Site { Location = "westus2", ServerFarmId = plan.Id, SiteConfig = new SiteConfig { LinuxFxVersion = String.Format("DOCKER|{0}.azurecr.io/{1}", _acrName, imageName), AppSettings = new List <NameValuePair> { //new NameValuePair("DOCKER_REGISTRY_SERVER_USERNAME", _acrName), new NameValuePair("DOCKER_REGISTRY_SERVER_PASSWORD", acrPassword), new NameValuePair("DOCKER_REGISTRY_SERVER_URL", string.Format("https://{0}.azurecr.io", _acrName)), new NameValuePair("DOCKER_ENABLE_CI", "false"), new NameValuePair("WEBSITES_ENABLE_APP_SERVICE_STORAGE", "false") } } }); //get publishing profile var publishingProfile = _webappClient.WebApps.ListPublishingCredentials(_rgName, appName); //clone app repo String timeStamp = DateTime.Now.ToString("yyyyMMddHHmmss"); String random = new Random().Next(0, 9999).ToString(); String path = String.Format("D:\\local\\Temp\\blimp{0}{1}", timeStamp, random); gitHubUtils.Clone(targetRepo, path, "master"); //push repo gitHubUtils.Push(path, "master", publishingProfile.ScmUri + "/" + appName + ".git"); gitHubUtils.Delete(path); return(""); } catch (Exception e) { if (tries >= 3) { throw e; } System.Threading.Thread.Sleep(60 * 1000); tries = tries + 1; } } }