Skip to content

Commit a5a50b4

Browse files
Fix GitHubWorkflowRun constructor and Remove-GitHubWorkflowRun error handling
1 parent 02cb87b commit a5a50b4

2 files changed

Lines changed: 31 additions & 27 deletions

File tree

src/classes/public/Workflows/GitHubWorkflowRun.ps1

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -103,34 +103,34 @@
103103

104104
GitHubWorkflowRun([PSCustomObject] $Object) {
105105
# From GitHubNode
106-
$this.ID = $_.id
107-
$this.NodeID = $_.node_id
106+
$this.ID = $Object.id
107+
$this.NodeID = $Object.node_id
108108

109109
# From GitHubWorkflowRun
110-
$this.Name = $_.name
110+
$this.Name = $Object.name
111111
$this.Owner = [GitHubOwner]::new($Object.repository.owner)
112112
$this.Repository = [GitHubRepository]::new($Object.repository)
113-
$this.CheckSuiteID = $_.check_suite_id
114-
$this.CheckSuiteNodeID = $_.check_suite_node_id
115-
$this.HeadBranch = $_.head_branch
116-
$this.HeadSha = $_.head_sha
117-
$this.Path = $_.path
118-
$this.RunNumber = $_.run_number
119-
$this.RunAttempt = $_.run_attempt
120-
$this.ReferencedWorkflows = $_.referenced_workflows
121-
$this.Event = $_.event
122-
$this.Status = $_.status
123-
$this.Conclusion = $_.conclusion
124-
$this.WorkflowID = $_.workflow_id
125-
$this.Url = $_.html_url
126-
$this.PullRequests = $_.pull_requests
127-
$this.CreatedAt = $_.created_at
128-
$this.UpdatedAt = $_.updated_at
129-
$this.StartedAt = $_.run_started_at
130-
$this.Actor = [GitHubUser]::new($_.actor)
131-
$this.TriggeringActor = [GitHubUser]::new($_.triggering_actor)
132-
$this.HeadCommit = $_.head_commit
133-
$this.HeadRepository = [GitHubRepository]::new($_.head_repository)
134-
$this.DisplayTitle = $_.display_title
113+
$this.CheckSuiteID = $Object.check_suite_id
114+
$this.CheckSuiteNodeID = $Object.check_suite_node_id
115+
$this.HeadBranch = $Object.head_branch
116+
$this.HeadSha = $Object.head_sha
117+
$this.Path = $Object.path
118+
$this.RunNumber = $Object.run_number
119+
$this.RunAttempt = $Object.run_attempt
120+
$this.ReferencedWorkflows = $Object.referenced_workflows
121+
$this.Event = $Object.event
122+
$this.Status = $Object.status
123+
$this.Conclusion = $Object.conclusion
124+
$this.WorkflowID = $Object.workflow_id
125+
$this.Url = $Object.html_url
126+
$this.PullRequests = $Object.pull_requests
127+
$this.CreatedAt = $Object.created_at
128+
$this.UpdatedAt = $Object.updated_at
129+
$this.StartedAt = $Object.run_started_at
130+
$this.Actor = [GitHubUser]::new($Object.actor)
131+
$this.TriggeringActor = [GitHubUser]::new($Object.triggering_actor)
132+
$this.HeadCommit = $Object.head_commit
133+
$this.HeadRepository = [GitHubRepository]::new($Object.head_repository)
134+
$this.DisplayTitle = $Object.display_title
135135
}
136136
}

src/functions/public/Workflows/Runs/Remove-GitHubWorkflowRun.ps1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,12 @@
5959
}
6060

6161
if ($PSCmdlet.ShouldProcess("$Owner/$Repository/$ID", 'Delete workflow run')) {
62-
Write-Verbose "Deleted workflow run [$ID] in [$Owner/$Repository]"
63-
$null = Invoke-GitHubAPI @apiParams
62+
try {
63+
$null = Invoke-GitHubAPI @apiParams
64+
Write-Verbose "Deleted workflow run [$ID] in [$Owner/$Repository]"
65+
} catch {
66+
Write-Error "Failed to delete workflow run [$ID] in [$Owner/$Repository]: $_"
67+
}
6468
}
6569
}
6670

0 commit comments

Comments
 (0)