-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathRemove-GitHubWorkflowRun.ps1
More file actions
76 lines (62 loc) · 2.58 KB
/
Copy pathRemove-GitHubWorkflowRun.ps1
File metadata and controls
76 lines (62 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
filter Remove-GitHubWorkflowRun {
<#
.SYNOPSIS
Delete a workflow run
.DESCRIPTION
Delete a specific workflow run. Anyone with write access to the repository can use this endpoint. If the repository is
private you must use an access token with the `repo` scope. GitHub Apps must have the `actions:write` permission to use
this endpoint.
.EXAMPLE
```powershell
Remove-GitHubWorkflowRun -Owner 'octocat' -Repository 'Hello-World' -ID 123456789
```
Deletes the workflow run with the ID 123456789 from the 'Hello-World' repository owned by 'octocat'
.INPUTS
GitHubWorkflowRun
.LINK
https://psmodule.io/GitHub/Functions/Workflows/Runs/Remove-GitHubWorkflowRun/
.NOTES
[Delete a workflow run](https://docs.github.com/rest/actions/workflow-runs#delete-a-workflow-run)
#>
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'High')]
param(
# The account owner of the repository. The name is not case sensitive.
[Parameter(Mandatory, ValueFromPipelineByPropertyName)]
[string] $Owner,
# The name of the repository without the .git extension. The name is not case sensitive.
[Parameter(Mandatory, ValueFromPipelineByPropertyName)]
[string] $Repository,
# The unique identifier of the workflow run.
[Parameter(Mandatory, ValueFromPipelineByPropertyName)]
[string] $ID,
# The context to run the command in. Used to get the details for the API call.
# Can be either a string or a GitHubContext object.
[Parameter()]
[object] $Context
)
begin {
$stackPath = Get-PSCallStackPath
Write-Debug "[$stackPath] - Start"
$Context = Resolve-GitHubContext -Context $Context
Assert-GitHubContext -Context $Context -AuthType IAT, PAT, UAT
}
process {
$apiParams = @{
Method = 'DELETE'
APIEndpoint = "repos/$Owner/$Repository/actions/runs/$ID"
Context = $Context
}
if ($PSCmdlet.ShouldProcess("$Owner/$Repository/$ID", 'Delete workflow run')) {
try {
$null = Invoke-GitHubAPI @apiParams
Write-Verbose "Deleted workflow run [$ID] in [$Owner/$Repository]"
} catch {
Write-Error "Failed to delete workflow run [$ID] in [$Owner/$Repository]: $_"
}
}
}
end {
Write-Debug "[$stackPath] - End"
}
}
#SkipTest:FunctionTest:Will add a test for this function in a future PR