|
| 1 | +param( |
| 2 | +# The issue state. Can be open, closed, or all |
| 3 | +[ValidateSet('open','closed','all')] |
| 4 | +[string] |
| 5 | +$IssueState = $(if ($env:IssueState) { $env:IssueState } else { 'all' }), |
| 6 | + |
| 7 | +# The issue label. |
| 8 | +[string[]] |
| 9 | +$IssueLabel = $(if ($env:IssueLabel) { $env:IssueLabel } else { @() }), |
| 10 | +) |
| 11 | + |
1 | 12 | if (-not $gitHubEvent.issue -and -not $gitHubEvent.discussion) { |
2 | 13 | Write-Warning "GitHub Event is not an issue or discussion, will not sync" |
3 | 14 | } |
4 | 15 |
|
5 | | -Start-Sleep -Seconds (Get-Random -Minimum 10 -Maximum 20) |
6 | | -git merge origin/main | Out-Host |
7 | | -git pull | Out-Host |
8 | | - |
9 | | -if ($GitHubToken) { |
| 16 | +if ($env:GitHubToken) { |
10 | 17 | "GitHub Token is present" | Out-Host |
11 | 18 | } |
12 | | -if ($GitHubToken -and $env:GIHUB_REPOSIORY) { |
13 | | - $owner, $repo = $env:GIHUB_REPOSIORY -split '/' |
| 19 | +if ($GitHubToken -and $env:GITHUB_REPOSIORY) { |
| 20 | + $owner, $repo = $env:GITHUB_REPOSIORY -split '/' |
14 | 21 | "Getting issues for $owner, $repo" | Out-Host |
| 22 | + $queryString = @( |
| 23 | + if ($IssueState) { |
| 24 | + "state=$($issueState.ToLower())" |
| 25 | + } |
| 26 | + if ($IssueLabel) { |
| 27 | + "labels=$($IssueLabel -join ',')" |
| 28 | + } |
| 29 | + 'per_page=100' |
| 30 | + ) -join '&' |
| 31 | + $issues = |
| 32 | + Invoke-RestMethod -Uri "https://api.github.com/repos/$owner/$repo/issues?$queryString" -Headers @{ |
| 33 | + "Authorization" = "token $GitHubToken" |
| 34 | + } |
| 35 | + foreach ($issue in $issues) { |
| 36 | + $psJekyll.CurrentSite.Data = @{"issues/$($issue.number)" = $issue} |
| 37 | + } |
15 | 38 | } else { |
16 | 39 | if ($gitHubEvent.issue) { |
17 | 40 | $psJekyll.CurrentSite.Data = @{"issues/$($gitHubEvent.issue.number)" = $gitHubEvent.issue} |
|
0 commit comments