-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
OSOE-506: Authenticate GitHub API request with GITHUB_TOKEN
- Loading branch information
Showing
3 changed files
with
9 additions
and
12 deletions.
There are no files selected for viewing
15 changes: 6 additions & 9 deletions
15
.github/actions/verify-submodule-pull-request/Check-Parent.ps1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,18 @@ | ||
param( | ||
param( | ||
[string] $Repository, | ||
[string] $Branch | ||
) | ||
|
||
$requestParameters = @{ | ||
Uri = "https://api.github.com/repos/$Repository/pulls?state=open&per_page=100" | ||
Method = "Get" | ||
Headers = @{ Accept = "application/vnd.github.v3+json" } | ||
} | ||
$titles = (Invoke-WebRequest @requestParameters).Content | ConvertFrom-Json | ForEach-Object { $PSItem.title } | ||
|
||
if (!($Branch -match '(\w+-\d+)')) | ||
{ | ||
exit | ||
} | ||
|
||
$url = "https://api.github.com/repos/$Repository/pulls?state=open&per_page=100" | ||
$response = Invoke-WebRequest $url -Headers (Get-GitHubApiAuthorizationHeader) -Method Get | ||
$titles = $response.Content | ConvertFrom-Json | ForEach-Object { $PSItem.title } | ||
|
||
$issueCode = $matches[0] | ||
$lookFor = "${issueCode}:" | ||
if (($titles | Where-Object { $PSItem -and $PSItem.Trim().StartsWith($lookFor) }).Count -gt 0) { exit 0 } | ||
Set-Failed "Couldn't find any pull request whose title starts with `"$lookFor`" in $Repository. Please create one." | ||
Set-Failed "Couldn't find any pull request whose title starts with `"$lookFor`" in $Repository. Please create one." |
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
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