]> us-delaporte.pagekite.me Git - dotfiles.git/commitdiff
A couple of GitHub API helper functions.
authorEdward Delaporte <delaport@illinois.edu>
Fri, 16 Apr 2021 20:00:13 +0000 (15:00 -0500)
committerEdward Delaporte <delaport@illinois.edu>
Fri, 16 Apr 2021 20:00:13 +0000 (15:00 -0500)
Useful to create lists for celebration of victories!

psmodules/github.psm1 [new file with mode: 0644]
setup/powershell.ps1

diff --git a/psmodules/github.psm1 b/psmodules/github.psm1
new file mode 100644 (file)
index 0000000..0f26e24
--- /dev/null
@@ -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
index 6dffb0f32317cd191e756a3a3c69de1667524b15..365629b6bfb5e0ea3317823127214775b20ec7d4 100755 (executable)
@@ -1,3 +1,5 @@
 Write-Host "Require remote scripts to be signed."\r
 Set-ExecutionPolicy RemoteSigned\r
+Set-PSRepository -Name PSGallery -InstallationPolicy Trusted # Trust PowerShell Gallery\r
 Install-Module posh-git\r
+Install-Module -Name PowerShellForGitHub
\ No newline at end of file