From e2cf7710c321264bf258c6c0e663b721302421bc Mon Sep 17 00:00:00 2001 From: Edward Delaporte Date: Fri, 16 Apr 2021 15:00:13 -0500 Subject: [PATCH] A couple of GitHub API helper functions. Useful to create lists for celebration of victories! --- psmodules/github.psm1 | 43 +++++++++++++++++++++++++++++++++++++++++++ setup/powershell.ps1 | 2 ++ 2 files changed, 45 insertions(+) create mode 100644 psmodules/github.psm1 diff --git a/psmodules/github.psm1 b/psmodules/github.psm1 new file mode 100644 index 0000000..0f26e24 --- /dev/null +++ b/psmodules/github.psm1 @@ -0,0 +1,43 @@ +<# +.SYNPOSIS + +Fetch closed GitHub issues that were updated in the last 14 days. + +#> +function Get-GHClosed { + param( + [int]$days = -14 + ) + $repos = @('SecOps-Tools', 'secdev-job-aids', 'awscli-login') + $issueSearchParams = @{ State = 'closed'; OwnerName = 'techservicesillinois' } + $closed = @() + $repos | ForEach-Object { + $closed += Get-GitHubIssue -RepositoryName $_ @issueSearchParams + } + + # Limit to past two weeks + $issues = $closed | Where-Object { $_.updated_at -gt (Get-Date).AddDays($days) } + return $issues +} + + +<# +.SYNOPSIS + +Show closed GitHub issues that were updated in the last 14 days. + +#> +function Show-GHClosed() { + param( + [int]$days = -14 + ) + Get-GHClosed -days $days | ForEach-Object { + # Markdown output + " + [" + $_.Title + " (" + $_.Number + ")](" + $_.html_url + ")" + } + # Format-Table -Property Number, Title, Url + +} + +Export-ModuleMember -Function Get-GHClosed +Export-ModuleMember -Function Show-GHClosed \ No newline at end of file diff --git a/setup/powershell.ps1 b/setup/powershell.ps1 index 6dffb0f..365629b 100755 --- a/setup/powershell.ps1 +++ b/setup/powershell.ps1 @@ -1,3 +1,5 @@ Write-Host "Require remote scripts to be signed." Set-ExecutionPolicy RemoteSigned +Set-PSRepository -Name PSGallery -InstallationPolicy Trusted # Trust PowerShell Gallery Install-Module posh-git +Install-Module -Name PowerShellForGitHub \ No newline at end of file -- 2.47.3