Last active
May 10, 2023 14:27
-
-
Save anderssonjohan/738ccf7beb01bfbadb94da21e05d0d6a to your computer and use it in GitHub Desktop.
Get and delete deployments for a github repository
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
$owner, | |
$repository_name, | |
$databaseid | |
) | |
gh api --method DELETE -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/$owner/$repository_name/deployments/$databaseid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
[parameter(mandatory, valuefrompipelinebypropertyname)] | |
[string] $owner, | |
[parameter(mandatory, valuefrompipelinebypropertyname)] | |
[string] $name | |
) | |
begin { | |
function getDeploymentsQuery($owner, $name) { | |
@" | |
{ | |
repository(name: "$name", owner: "$owner") { | |
id | |
deployments(first: 10, orderBy: {field: CREATED_AT, direction: DESC}, environments: "production") { | |
nodes { | |
environment | |
state | |
databaseId | |
createdAt | |
} | |
} | |
} | |
} | |
"@ | |
} | |
} | |
process { | |
$query = getDeploymentsQuery $owner $name | |
$result = ./execute-graphql.ps1 $query | |
$result | % repository | % deployments | % nodes ` | |
| add-member -PassThru -Name repository_name -Value $name -MemberType NoteProperty ` | |
| add-member -PassThru -Name owner -Value $owner -MemberType NoteProperty | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment