Skip to content

Commit

Permalink
Support pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
dstrome authored Jul 17, 2024
1 parent 4680bab commit 0a75e09
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/Shared-ProtectedFiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
If (($GitRequestEvent -eq "pull_request_target") -and (($GitHubData.event.action -eq "opened") -or ($GitHubData.event.action -eq "synchronize") -or ($GitHubData.event.action -eq "reopened"))) {
# Collect info from payload that we'll need to process the PR
$FileListUrl = "$($GitHubData.event.pull_request.url)/files"
$FileListUrl = "$($GitHubData.event.pull_request.url)/files?per_page=100"
$PrSubmitter = $GitHubData.event.pull_request.user.login
$PrSubmitterPermissionsUrl = $GitHubData.event.repository.collaborators_url.Replace("{/collaborator}", "/$PrSubmitter/permission")
$StatusUrl = $GitHubData.event.pull_request.statuses_url
Expand Down Expand Up @@ -107,9 +107,14 @@ jobs:
# Get the list of files modified in the PR.
# Get the permissions of the PR submitter.
$FileList = Invoke-RestMethod -Method GET -ContentType "application/json" -Headers $GitHubHeaders -Uri $FileListUrl -ErrorAction Stop
$FileListData = Invoke-RestMethod -Method GET -ContentType "application/json" -Headers $GitHubHeaders -Uri $FileListUrl -FollowRelLink -MaximumFollowRelLink 50 -ErrorAction Stop
$PrSubmitterPerms = Invoke-RestMethod -Method GET -ContentType "application/json" -Headers $GitHubHeaders -Uri $PrSubmitterPermissionsUrl -ErrorAction Stop
$FileList = @()
# Collapse pages into a single list if there are any and store in $FileList
ForEach ($Page in $FileListData) { $FileList += $Page }
$ProtectedFileFound = $False
# Only process PRs that actually have changed files.
Expand Down Expand Up @@ -275,4 +280,4 @@ jobs:
}
}

0 comments on commit 0a75e09

Please sign in to comment.