You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🚀 [Minor]: GitHub API rate limit details now available in action logs (#89)
GitHub API rate limit consumption is now visible directly in the action
logs. When enabled, rate limit details - including remaining quota,
limit, used count, and reset time for all resource categories - are
displayed before and after the user script runs, making it easy to see
exactly how many API calls a workflow step consumed.
- Fixes#88
## New: Rate limit visibility in action logs
A new `ShowRateLimit` input (default: `'false'`) controls whether rate
limit information appears in the logs. When set to `'true'`, a **Rate
Limits** LogGroup appears inside the Info fence before the user script,
and another **Rate Limits** LogGroup appears inside the Outputs fence
after it.
```yaml
- uses: PSModule/GitHub-Script@v1
with:
ShowRateLimit: 'true'
Script: |
Get-GitHubRepository -Owner PSModule -Name GitHub-Script
```
The output includes a formatted table of all resource categories
returned by `Get-GitHubRateLimit` (core, search, graphql, etc.), each
showing `Limit`, `Used`, `Remaining`, `ResetsAt`, and `ResetsIn`.
When the input is omitted or set to `'false'` (the default), no rate
limit output appears.
If `ShowRateLimit` is enabled but `ShowInfo` or `ShowOutput` is off, the
corresponding fence still renders with just the rate limit content
inside. For auth types that do not support `Get-GitHubRateLimit` (for
example GitHub App contexts), a warning is shown instead of failing.
## Technical Details
- Added `ShowRateLimit` input to `action.yml` with `required: false` and
`default: 'false'`.
- Added `PSMODULE_GITHUB_SCRIPT_INPUT_ShowRateLimit` environment
variable to the composite step.
- Created `src/ratelimit.ps1` as a helper script (no fence borders) that
checks the guard and renders a single `Rate Limits` LogGroup.
- `src/ratelimit.ps1` now calls `Get-GitHubRateLimit -ErrorAction Stop`
so non-terminating errors are caught reliably in unsupported auth
contexts.
- `src/ratelimit.ps1` explicitly selects `Name`, `Limit`, `Used`,
`Remaining`, `ResetsAt`, and `ResetsIn` before formatting to keep
columns deterministic.
- Modified `src/info.ps1`: adjusted the early-return guard to also
consider `ShowRateLimit`, wrapped existing LogGroups in `if
($showInfo)`, and calls `ratelimit.ps1` before the fence close.
- Modified `src/outputs.ps1`: adjusted the early-return guard to also
consider `ShowRateLimit`, wrapped existing output LogGroups in `if
($result)`, and calls `ratelimit.ps1` before the fence close.
- The `action.yml` run block remains in the same flow, while `info.ps1`
and `outputs.ps1` invoke the helper internally.
- Enabled `ShowRateLimit: true` across all Action-Test scenarios in
`.github/workflows/TestWorkflow.yml`, including Basic, WithScript path
variants, Commands + Outputs, Matrix Creator, WithoutToken, WithPAT,
WithUserFGPAT, WithOrgFGPAT, GitHubAppEnt, GitHubAppOrg + quoted inputs,
WithKeyVaultKeyReference, WithKeyVaultKeyReferenceLatest, and
PreserveCredentials False.
---------
Co-authored-by: anthropic-code-agent[bot] <242468646+Claude@users.noreply.github.com>
Copy file name to clipboardExpand all lines: README.md
+14Lines changed: 14 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,7 @@ To get started with your own GitHub PowerShell based action, [create a new repos
24
24
|`ShowInfo`| Show information about the environment. | false |`'true'`|
25
25
|`ShowInit`| Show information about the initialization. | false |`'false'`|
26
26
|`ShowOutput`| Show the script's output. | false |`'false'`|
27
+
|`ShowRateLimit`| Show GitHub API rate limit information before and after script execution. | false |`'false'`|
27
28
|`WorkingDirectory`| The working directory where the script runs. | false |`'.'`|
28
29
|`PreserveCredentials`| Preserve credentials after script execution. If false, disconnects GitHub contexts and CLI using Disconnect-GitHubAccount. | false |`'true'`|
29
30
@@ -243,3 +244,16 @@ Runs a script with `PreserveCredentials` set to `false` to automatically disconn
243
244
Get-GitHubUser
244
245
# Credentials will be disconnected after this step
245
246
```
247
+
248
+
#### Example 8: Show GitHub API rate limit usage
249
+
250
+
Displays the GitHub API rate limit status before and after the script runs. The **Rate Limits** log group shows `Limit`, `Used`, `Remaining`, `ResetsAt`, and `ResetsIn` for every resource category (`core`, `search`, `graphql`, etc.), making it easy to see exactly how many API calls a workflow step consumed.
Copy file name to clipboardExpand all lines: action.yml
+5Lines changed: 5 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -53,6 +53,10 @@ inputs:
53
53
description: Show the output of the script.
54
54
required: false
55
55
default: 'false'
56
+
ShowRateLimit:
57
+
description: Show GitHub API rate limit information before and after script execution.
58
+
required: false
59
+
default: 'false'
56
60
ErrorView:
57
61
description: Configure the PowerShell `$ErrorView` variable. You can use full names ('NormalView', 'CategoryView', 'ConciseView', 'DetailedView'). It matches on partials.
0 commit comments