How to: Create Dashboard to visualize Branches ahead/behind on GitHub

  1. PowerShell script will receive the following parameters:
  • $PAT = Personal Access token to connect on GitHub organization;
  • $Organization = GitHub Organization name;
  • $Connstr = connection string to Azure SQL Database that stores the report information. To create this report, it’s necessary to create previously a Azure SQL Server and Database and run a script below:
$uriRepositories = "$($UriOrganization)/repos"$RepositoriesResult = Invoke-RestMethod -Headers $headers -Uri $uriRepositoriesforeach ($repo in $RepositoriesResult)
{
Write-Host $repo.name
Write-Host $repo.default_branch
}
$urlBranchesRepo = $repo.branches_url.Replace('{/branch}','')    $BranchesRepoResult = Invoke-RestMethod -Headers $headers -Uri $urlBranchesRepo    foreach ($branchRepo in $BranchesRepoResult)
{
Write-Host $branchRepo.name
}
$uriCompare = "$($UriRepos)/$($repo.name)/compare/$($repo.default_branch)...$($branchRepo.name)"        $ComparesResult = Invoke-RestMethod -Headers $headers -Uri $uriCompareWrite-Host $ComparesResult.ahead_by 
Write-Host $ComparesResult.behind_by
  • Repository Name (1) = Filter report using Repository Name field;
  • Branch Name (2) = Filter report using Branch Name field;
  • Branches Information (3) = List all information about Branches and Commits status (Repository, Branch, Behind Count, Ahead Count).

--

--

--

Tech Solution Architect Manager na Accenture

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Moodle Installation Guide for Ubuntu Linux (1)

JSFoo hack night, React & React Native workshops, computer vision meet up & memorial for Tim Poston

Changing these little things takes time because habits become ingrained in you from an

An enjoyable audit

Spelling Corrector in Python

I Am Dev Enough

Control Planes for Envoy

Oan uiv94j 9vdf94 §

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vinicius Moura

Vinicius Moura

Tech Solution Architect Manager na Accenture

More from Medium

How to: List GitHub default Branch protection rules

How to install code-server on cloud

Cheat sheet — Running a MSSQL Server instance using Docker Desktop

Gitlab SSH Config Host File, Allowing Multiple Account SSH Access