Skip to content

feat: centralize GitHub API requests with auth and retry logic#528

Merged
jaredfholgate merged 2 commits intomainfrom
feat/centralize-github-api-requests
Mar 25, 2026
Merged

feat: centralize GitHub API requests with auth and retry logic#528
jaredfholgate merged 2 commits intomainfrom
feat/centralize-github-api-requests

Conversation

@jaredfholgate
Copy link
Copy Markdown
Member

Summary

Introduces a centralized Invoke-GitHubApiRequest function that consolidates all GitHub API calls with:

  • Automatic authentication via GitHub CLI (gh auth token) when available, increasing API rate limits
  • Configurable retry logic for transient HTTP errors (408, 429, 500, 502, 503, 504)
  • Consistent error handling across all GitHub API interactions

Changes

New Function

  • Invoke-GitHubApiRequest — Central function for all GitHub HTTP requests with auth header injection and retry support

Updated Functions

  • Get-GithubRelease — Uses Invoke-GitHubApiRequest instead of Invoke-WebRequest for downloading release artifacts
  • Get-GithubReleaseTag — Uses Invoke-GitHubApiRequest instead of Invoke-RestMethod with inline retry logic removed
  • Get-HCLParserTool — Uses Invoke-GitHubApiRequest for downloading HCL parser binaries
  • Test-NetworkConnectivity — Routes api.github.com connectivity check through Invoke-GitHubApiRequest
  • New-ModuleSetup — Propagates maxRetryCount parameter; fixes isFirstRunfirstRun variable references
  • New-FolderStructure — Accepts and passes through maxRetryCount parameter
  • Deploy-Accelerator — Adds github_max_retry_count parameter (alias: gmrc, githubMaxRetryCount)

Tests

  • Updated Test-NetworkConnectivity.Tests.ps1 to mock Invoke-GitHubApiRequest for the GitHub API endpoint

- Add Invoke-GitHubApiRequest function that centralizes all GitHub API
  calls with automatic gh CLI authentication and configurable retry
  logic for transient errors (408, 429, 5xx).
- Update Get-GithubRelease, Get-GithubReleaseTag, Get-HCLParserTool,
  and Test-NetworkConnectivity to use the new centralized function.
- Add github_max_retry_count parameter to Deploy-Accelerator to allow
  configuring max retries for GitHub API calls.
- Propagate maxRetryCount through New-ModuleSetup and New-FolderStructure.
- Fix variable name references (isFirstRun -> firstRun) in New-ModuleSetup.
jtracey93
jtracey93 previously approved these changes Mar 25, 2026
@github-actions github-actions bot added the Needs: Triage 🔍 Needs triaging by the team label Mar 25, 2026
@jaredfholgate jaredfholgate merged commit fffb47e into main Mar 25, 2026
6 checks passed
@jaredfholgate jaredfholgate deleted the feat/centralize-github-api-requests branch March 25, 2026 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs: Triage 🔍 Needs triaging by the team

Projects

Development

Successfully merging this pull request may close these issues.

2 participants