Last active
March 26, 2018 13:42
-
-
Save RyKilleen/df134af71125309b0590 to your computer and use it in GitHub Desktop.
Powershell Script
This file contains hidden or 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
<# | |
.SYNOPSIS | |
Send an array of labels to a Github Repo | |
.DESCRIPTION | |
.EXAMPLE | |
Post-GithubLabels "##############" "myOrganization" "myRepo" '[{"name": "bug","color": "fc2929"},{"name": "duplicate","color": "cccccc"}]'' | |
.NOTES | |
Author : Ryan Killeen | |
#> | |
function Post-GithubLabels($token, $orgOrUser, $repoName, $labels) { | |
$postURL = "https://api.github.com/repos/" + $orgOrUser + "/" + $repoName + "/labels?access_token=" + $token | |
Write-Host $postURL | |
$labelsAsObj = $labels | ConvertFrom-Json | |
Foreach($label in $labelsAsObj) { | |
$payload = $label | ConvertTo-Json | |
$postResponse = Invoke-RestMethod $postURL -Method Post -Body $payload -ContentType 'application/json' | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment