Skip to content

Commit 7e4d973

Browse files
authored
Delete winget-pkgs fork before running winget-create (#522)
1 parent cc16800 commit 7e4d973

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

.octopus/deployment_process.ocl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,26 @@ step "publish-winget-update-pr" {
215215
action_type = "Octopus.Script"
216216
properties = {
217217
Octopus.Action.Script.ScriptBody = <<-EOT
218+
#Headers
219+
$headers = @{
220+
'Accept' = "application/vnd.github+json";
221+
'X-GitHub-Api-Version' = "2022-11-28";
222+
}
223+
try {
224+
225+
# Delete the fork of the winget-pkgs repo using the bot's token
226+
$response = Invoke-WebRequest -Method "DELETE" -Uri "https://api.github.com/repos/team-integrations-fnm-bot/winget-pkgs" -Authentication "Bearer" -Token $OctopusParameters["Publish:Winget:GitHubPAT"] -Headers $headers
227+
$statusCode = $Response.StatusCode
228+
}
229+
catch {
230+
$statusCode = $_.Exception.Response.StatusCode.value__
231+
}
232+
233+
if (!($statusCode -ge 200 -and $statusCode -le 299 )) {
234+
Write-Warning "Failed to delete fork repo 'team-integrations-fnm-bot/winget-pkgs'. If this fork is too far behind its source, winget-create may fail."
235+
}
236+
237+
218238
# Install winget-create
219239
Invoke-WebRequest https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe
220240

0 commit comments

Comments
 (0)