Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add ShowRateLimit option to display API rate limits before and after …
…script execution
  • Loading branch information
MariusStorhaug committed Apr 13, 2026
commit 27ecb45c630873139a080e695efa7529db976eae
9 changes: 9 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
description: Show the output of the script.
required: false
default: 'false'
ShowRateLimit:
description: Show GitHub API rate limit information before and after script execution.
required: false
default: 'false'
Comment thread
MariusStorhaug marked this conversation as resolved.
ErrorView:
description: Configure the PowerShell `$ErrorView` variable. You can use full names ('NormalView', 'CategoryView', 'ConciseView', 'DetailedView'). It matches on partials.
required: false
Expand Down Expand Up @@ -91,6 +95,7 @@
PSMODULE_GITHUB_SCRIPT_INPUT_ShowInfo: ${{ inputs.ShowInfo }}
PSMODULE_GITHUB_SCRIPT_INPUT_ShowOutput: ${{ inputs.ShowOutput }}
PSMODULE_GITHUB_SCRIPT_INPUT_Prerelease: ${{ inputs.Prerelease }}
PSMODULE_GITHUB_SCRIPT_INPUT_ShowRateLimit: ${{ inputs.ShowRateLimit }}
PSMODULE_GITHUB_SCRIPT_INPUT_ErrorView: ${{ inputs.ErrorView }}
PSMODULE_GITHUB_SCRIPT_INPUT_PreserveCredentials: ${{ inputs.PreserveCredentials }}
run: |
Expand All @@ -101,8 +106,12 @@
try {
${{ github.action_path }}/src/init.ps1
${{ github.action_path }}/src/info.ps1
$env:PSMODULE_GITHUB_SCRIPT_RATELIMIT_LABEL = 'Pre'
${{ github.action_path }}/src/ratelimit.ps1

Check warning

Code scanning / CodeQL

Code injection Medium

Potential code injection in
${ github.action_path }
, which may be controlled by an external user.
Comment thread
MariusStorhaug marked this conversation as resolved.
Fixed
${{ inputs.Script }}
${{ github.action_path }}/src/outputs.ps1
$env:PSMODULE_GITHUB_SCRIPT_RATELIMIT_LABEL = 'Post'
${{ github.action_path }}/src/ratelimit.ps1

Check warning

Code scanning / CodeQL

Code injection Medium

Potential code injection in
${ github.action_path }
, which may be controlled by an external user.
Comment thread
MariusStorhaug marked this conversation as resolved.
Fixed
}
finally {
${{ github.action_path }}/src/clean.ps1
Expand Down
30 changes: 30 additions & 0 deletions src/ratelimit.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#Requires -Modules GitHub

[CmdletBinding()]
param()

$scriptName = $MyInvocation.MyCommand.Name
Write-Debug "[$scriptName] - Start"

try {
if ($env:PSMODULE_GITHUB_SCRIPT_INPUT_ShowRateLimit -ne 'true') {
return
}

$fenceTitle = $env:PSMODULE_GITHUB_SCRIPT_INPUT_Name
$label = $env:PSMODULE_GITHUB_SCRIPT_RATELIMIT_LABEL

$fenceStart = "┏━━┫ $fenceTitle - Rate Limit ($label) ┣━━━━━━━━┓"
Write-Output $fenceStart

LogGroup " - Rate Limit ($label)" {
Get-GitHubRateLimit | Format-Table -AutoSize | Out-String
Comment thread
MariusStorhaug marked this conversation as resolved.
Outdated
}

$fenceEnd = '┗' + ('━' * ($fenceStart.Length - 2)) + '┛'
Write-Output $fenceEnd
} catch {
throw $_
}

Write-Debug "[$scriptName] - End"
Loading