Skip to content

Instantly share code, notes, and snippets.

@jenol
Created March 11, 2022 13:45
Show Gist options
  • Save jenol/9e8c8f6a251d8b0282a7341833d241f6 to your computer and use it in GitHub Desktop.
Save jenol/9e8c8f6a251d8b0282a7341833d241f6 to your computer and use it in GitHub Desktop.
$ErrorActionPreference = "Stop"
$githubAuth = "get your own token"
$organization = "your org"
$repoName = "your repo"
$repo = Invoke-RestMethod -Method Get -Uri "https://api.github.com/repos/$organization/$repoName" -Headers @{
Authorization = "bearer $githubAuth"
Accept = "application/vnd.github.v3+json"
} -Body $body -UseBasicParsing
$mainBranchName = $repo.default_branch
$mainBranch = Invoke-RestMethod -Method Get -Uri "https://api.github.com/repos/$organization/$repoName/branches/$mainBranchName" -Headers @{
Authorization = "bearer $githubAuth"
Accept = "application/vnd.github.v3+json"
} -Body $body -UseBasicParsing
$trees = Invoke-RestMethod -Method Get -Uri "https://api.github.com/repos/$organization/$repoName/git/trees/$($mainBranch.commit.sha)?recursive=1" -Headers @{
Authorization = "bearer $githubAuth"
Accept = "application/vnd.github.v3+json"
} -Body $body -UseBasicParsing
$trees.truncated
$trees.tree
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment