public override bool Execute() { string contents = System.IO.File.ReadAllText(ManifestFile); var model = OrchestratedBuildModel.Parse(XElement.Parse(contents)); if (string.IsNullOrEmpty(CommitMessage)) { CommitMessage = $"{model.Identity} orchestrated build manifest"; } var gitHubAuth = new GitHubAuth(GitHubAuthToken, GitHubUser, GitHubEmail); using (var gitHubClient = new GitHubClient(gitHubAuth)) { var client = new BuildManifestClient(gitHubClient); var location = new BuildManifestLocation( new GitHubProject(VersionsRepo, VersionsRepoOwner), $"heads/{VersionsRepoBranch}", VersionsRepoPath); var pushTask = client.PushNewBuildAsync( location, model, CreateUploadRequests(SupplementaryFiles), CommitMessage); pushTask.Wait(); } return(!Log.HasLoggedErrors); }
private async System.Threading.Tasks.Task PushChangeAsync(BuildManifestClient client) { try { var location = new BuildManifestLocation( new GitHubProject(VersionsRepo, VersionsRepoOwner), $"heads/{VersionsRepoBranch}", VersionsRepoPath); IEnumerable <JoinSemaphoreGroup> joinGroups = JoinSemaphoreGroups .Select(item => new { ParallelPartPath = item.ItemSpec, JoinSemaphorePath = item.GetMetadata(JoinSemaphorePathMetadataName) }) .GroupBy(j => j.JoinSemaphorePath, j => j.ParallelPartPath) .Select(g => new JoinSemaphoreGroup { JoinSemaphorePath = g.Key, ParallelSemaphorePaths = g }); SupplementaryUploadRequest[] supplementaryUploads = PushOrchestratedBuildManifest.CreateUploadRequests(SupplementaryFiles); var change = new BuildManifestChange( location, CommitMessage, OrchestratedBuildId, SemaphoreNames, manifest => { foreach (var update in ManifestUpdates ?? Enumerable.Empty <ITaskItem>()) { ApplyUpdate(manifest, update); } }) { SupplementaryUploads = supplementaryUploads, JoinSemaphoreGroups = joinGroups, }; await client.PushChangeAsync(change); } catch (ManifestChangeOutOfDateException e) { Log.LogWarningFromException(e); } }